Skip to content

Commit

Permalink
Fix No final redraw when max_refresh_rate is set
Browse files Browse the repository at this point in the history
  • Loading branch information
yfery committed Jun 29, 2017
1 parent fe5f8ba commit ffb5d50
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 @@ -309,7 +309,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 @@ -107,3 +107,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 ffb5d50

Please sign in to comment.