WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 7e5288d

Browse files
authored
Prevent changing current maximum on Finish (#82)
1 parent 782793f commit 7e5288d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

progressbar.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,10 +398,12 @@ func (p *ProgressBar) Add64(num int64) error {
398398
return errors.New("max must be greater than 0")
399399
}
400400

401-
if p.config.ignoreLength {
402-
p.state.currentNum = (p.state.currentNum + num) % p.config.max
403-
} else {
404-
p.state.currentNum += num
401+
if p.state.currentNum < p.config.max {
402+
if p.config.ignoreLength {
403+
p.state.currentNum = (p.state.currentNum + num) % p.config.max
404+
} else {
405+
p.state.currentNum += num
406+
}
405407
}
406408

407409
p.state.currentBytes += float64(num)

0 commit comments

Comments
 (0)