Skip to content

Commit 79ea085

Browse files
authored
Add ProgressBar::force_draw (#689)
1 parent fe59003 commit 79ea085

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/progress_bar.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,17 @@ impl ProgressBar {
423423
state.draw_target = target;
424424
}
425425

426+
/// Force a redraw of the progress bar to be in sync with its state
427+
///
428+
/// For performance reasons the progress bar is not redrawn on each state update.
429+
/// This is normally not an issue, since new updates will eventually trigger rendering.
430+
///
431+
/// For slow running tasks it is recommended to rely on [`ProgressBar::enable_steady_tick()`]
432+
/// to ensure continued rendering of the progress bar.
433+
pub fn force_draw(&self) {
434+
let _ = self.state().draw(true, Instant::now());
435+
}
436+
426437
/// Hide the progress bar temporarily, execute `f`, then redraw the progress bar
427438
///
428439
/// Useful for external code that writes to the standard output.

0 commit comments

Comments
 (0)