Skip to content

Commit

Permalink
Merge pull request #53 from yfery/FinalRedrawWhenMaxRefreshRateSet
Browse files Browse the repository at this point in the history
Fix No final redraw when max_refresh_rate is set
  • Loading branch information
a8m committed Sep 21, 2019
2 parents 7714f4e + ffb5d50 commit 9fa7b0e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/pb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ impl<T: Write> ProgressBar<T> {
fn draw(&mut self) {
let now = SteadyTime::now();
if let Some(mrr) = self.max_refresh_rate {
if now - self.last_refresh_time < mrr {
if now - self.last_refresh_time < mrr && self.current < self.total {
return;
}
}
Expand Down
15 changes: 15 additions & 0 deletions tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,18 @@ fn npm_bar() {
}
pb.finish_println("done!");
}

#[test]
// see: issue 45#
fn final_redraw_max_refresh_rate() {
let count = 500;
let mut pb = ProgressBar::new(count);
pb.format("╢▌▌░╟");
pb.set_max_refresh_rate(Some(Duration::from_millis(100)));
for _ in 0..count {
pb.inc();
thread::sleep(Duration::from_millis(5));
}
pb.finish_println("done!");
}

0 comments on commit 9fa7b0e

Please sign in to comment.