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

Merged

Conversation

black-night-heron
Copy link
Contributor

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)

@schollz
Copy link
Owner

schollz commented May 20, 2024

thanks for this fix!

@schollz schollz merged commit 37cfbad into schollz:main May 20, 2024
1 check passed
renovate bot added a commit to nobl9/sloctl that referenced this pull request May 20, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[github.com/schollz/progressbar/v3](https://togithub.com/schollz/progressbar)
| `v3.14.2` -> `v3.14.3` |
[![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fschollz%2fprogressbar%2fv3/v3.14.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fschollz%2fprogressbar%2fv3/v3.14.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fschollz%2fprogressbar%2fv3/v3.14.2/v3.14.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fschollz%2fprogressbar%2fv3/v3.14.2/v3.14.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>schollz/progressbar
(github.com/schollz/progressbar/v3)</summary>

###
[`v3.14.3`](https://togithub.com/schollz/progressbar/releases/tag/v3.14.3)

[Compare
Source](https://togithub.com/schollz/progressbar/compare/v3.14.2...v3.14.3)

#### What's Changed

- fix error return by [@&#8203;ttmars](https://togithub.com/ttmars) in
[schollz/progressbar#175
- fix Finish() should update state.currentBytes by
[@&#8203;black-night-heron](https://togithub.com/black-night-heron) in
[schollz/progressbar#182
- fix race condition when changing max by
[@&#8203;mxey](https://togithub.com/mxey) in
[schollz/progressbar#183
- fix: make elapsedTime option work in non-spinner mode by
[@&#8203;wjf3121](https://togithub.com/wjf3121) in
[schollz/progressbar#184

#### New Contributors

- [@&#8203;ttmars](https://togithub.com/ttmars) made their first
contribution in
[schollz/progressbar#175
- [@&#8203;black-night-heron](https://togithub.com/black-night-heron)
made their first contribution in
[schollz/progressbar#182
- [@&#8203;mxey](https://togithub.com/mxey) made their first
contribution in
[schollz/progressbar#183
- [@&#8203;wjf3121](https://togithub.com/wjf3121) made their first
contribution in
[schollz/progressbar#184

**Full Changelog**:
schollz/progressbar@v3.14.2...v3.14.3

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 10pm every weekday,before 5am
every weekday,every weekend" (UTC), Automerge - At any time (no schedule
defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/nobl9/sloctl).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNjMuNSIsInVwZGF0ZWRJblZlciI6IjM3LjM2My41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiLCJnb2xhbmciLCJyZW5vdmF0ZSJdfQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
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

2 participants