Skip to content

Commit 37cfbad

Browse files
authored
Merge pull request #182 from black-night-heron/fix/finish-update-current-bytes
Finish() should update state.currentBytes
2 parents 1e76c26 + cc253fb commit 37cfbad

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

progressbar.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,10 +494,7 @@ func (p *ProgressBar) Reset() {
494494

495495
// Finish will fill the bar to full
496496
func (p *ProgressBar) Finish() error {
497-
p.lock.Lock()
498-
p.state.currentNum = p.config.max
499-
p.lock.Unlock()
500-
return p.Add(0)
497+
return p.Set64(p.config.max)
501498
}
502499

503500
// Exit will exit the bar to keep current state

progressbar_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,12 @@ func ExampleOptionClearOnFinish() {
9494
}
9595

9696
func ExampleProgressBar_Finish() {
97-
bar := NewOptions(100, OptionSetWidth(10))
97+
bar := NewOptions(100, OptionSetWidth(10), OptionShowCount(), OptionShowBytes(true), OptionShowIts())
98+
bar.Reset()
99+
time.Sleep(1 * time.Second)
98100
bar.Finish()
99101
// Output:
100-
// 100% |██████████|
102+
// 100% |██████████| (100/100 B, 100 B/s, 100 it/s)
101103
}
102104

103105
func Example_xOutOfY() {

0 commit comments

Comments
 (0)