Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finish() should update state.currentBytes #182

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

black-night-heron
Copy link

The current implementation of the Finish() function sets currentNum and invokes Add(0). While this correctly updates currentNum, it does not correctly update currentBytes. As a result, if OptionShowBytes, OptionShowIts, or OptionShowCount() options are enabled, the displayed counts or iterations will reflect incomplete values after calling Finish().

For example, consider the following Go code snippet:

package main

import (
	"time"
	"github.com/schollz/progressbar/v3"
)

func main() {
	bar := progressbar.NewOptions64(100, progressbar.OptionShowBytes(true), progressbar.OptionShowIts(), progressbar.OptionShowCount())
	bar.Add(50)
	time.Sleep(1 * time.Second)
	bar.Finish()
}

This code results in the following output:

100% |████████████████████████████████████████| (50/100 B, 50 B/s, 50 it/s)

However, the expected output should reflect the completion of the progress bar:

100% |████████████████████████████████████████| (100/100 B, 100 B/s, 100 it/s)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant