Skip to content

Commit

Permalink
resetting the elapsed time also resets ETA
Browse files Browse the repository at this point in the history
  • Loading branch information
afontenot authored and djc committed May 9, 2023
1 parent 3d5dbb3 commit 6d31845
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/progress_bar.rs
Expand Up @@ -307,7 +307,7 @@ impl ProgressBar {
self.state().reset(Instant::now(), Reset::Eta);
}

/// Resets elapsed time
/// Resets elapsed time and the ETA calculation
pub fn reset_elapsed(&self) {
self.state().reset(Instant::now(), Reset::Elapsed);
}
Expand Down
6 changes: 3 additions & 3 deletions src/state.rs
Expand Up @@ -69,9 +69,9 @@ impl BarState {
}

pub(crate) fn reset(&mut self, now: Instant, mode: Reset) {
if let Reset::Eta | Reset::All = mode {
self.state.est.reset(now);
}
// Always reset the estimator; this is the only reset that will occur if mode is
// `Reset::Eta`.
self.state.est.reset(now);

if let Reset::Elapsed | Reset::All = mode {
self.state.started = now;
Expand Down

0 comments on commit 6d31845

Please sign in to comment.