console-rs / indicatif

A command line progress reporting library for Rust
MIT License
4.23k stars 240 forks source link

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

Closed devmatteini closed 1 year ago

devmatteini commented 1 year ago

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 :smile:


OS: Ubuntu 22.04 Rust: 1.63.0

devmatteini commented 1 year ago

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

Looking at the diff, I found the problem here at line 223: https://github.com/console-rs/indicatif/blob/b138fef63ddc5ff1be420bedbbfb8660a4dc7cd8/src/state.rs#L220-L229

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%?