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

percent in ProgressStyle template starts from 100% instead of 0% #489

Closed
devmatteini opened this issue Oct 24, 2022 · 1 comment · Fixed by #491
Closed

percent in ProgressStyle template starts from 100% instead of 0% #489

devmatteini opened this issue Oct 24, 2022 · 1 comment · Fixed by #491

Comments

@devmatteini
Copy link
Contributor

Hi and thank you for maintaining this awesome crate!

After upgrading from 0.16.2 to 0.17.x I noticed that my spinner percent was always starting from 100% instead of 0%.

indicatif-percent-problems.webm

(I'm not sure if this is a related problem, but also the eta stopped working and always displays 0).

I created a simple repo to reproduce the issue: https://github.com/devmatteini/indicatif-percent-problems

Let me know if I can help somehow 😄


OS: Ubuntu 22.04
Rust: 1.63.0

@devmatteini
Copy link
Contributor Author

I did a git bisect and found the bad commit: b138fef

Looking at the diff, I found the problem here at line 223:

indicatif/src/state.rs

Lines 220 to 229 in b138fef

pub fn fraction(&self) -> f32 {
let pos = self.pos.pos.load(Ordering::Relaxed);
let pct = match (pos, self.len) {
(_, None) => 1.0,
(_, Some(0)) => 1.0,
(0, _) => 0.0,
(pos, Some(len)) => pos as f32 / len as f32,
};
pct.max(0.0).min(1.0)
}

If self.len is None the percent is set to 1.0 which means is full.

If there is no length (None), shouldn't we treat it as 0%?

devmatteini added a commit to devmatteini/indicatif that referenced this issue Nov 5, 2022
@djc djc closed this as completed in #491 Nov 6, 2022
djc pushed a commit that referenced this issue Nov 6, 2022
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 a pull request may close this issue.

1 participant