Skip to content

Commit

Permalink
do not throttle if has reached max
Browse files Browse the repository at this point in the history
  • Loading branch information
schollz committed Nov 2, 2018
1 parent bd5c916 commit 74139f2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion progressbar.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ func (p *ProgressBar) Clear() error {
// so it must be called with an acquired lock.
func (p *ProgressBar) render() error {
// make sure that the rendering is not happening too quickly
if time.Since(p.state.lastShown).Nanoseconds() < p.config.throttleDuration.Nanoseconds() {
// but always show if the currentNum reaches the max
if time.Since(p.state.lastShown).Nanoseconds() < p.config.throttleDuration.Nanoseconds() &&
p.state.currentNum < p.config.max {
return nil
}

Expand Down

0 comments on commit 74139f2

Please sign in to comment.