Skip to content

Fix duration after finish#748

Merged
djc merged 5 commits intoconsole-rs:mainfrom
luolong:duration-after-finish
Nov 18, 2025
Merged

Fix duration after finish#748
djc merged 5 commits intoconsole-rs:mainfrom
luolong:duration-after-finish

Conversation

@luolong
Copy link
Contributor

@luolong luolong commented Nov 18, 2025

When initializing progress bar with style that exposes template variable {duration}, the duration is set to 0 after progress bar finishes.

This is is unexpected and makes progress bar styles other than 'ProgressFinish::AndClear' display wrong duration.

This will add Duration parameter to crate::state::State::Done* variants and uses it to display duration if curret state of the progress bar is one of the Done states.

Fixes #557

When initializing progress bar with style that exposes template variable
`{duration}`, the duration is set to 0 after progress bar finishes.

This is is unexpected and makes progress bar styles other than
'ProgressFinish::AndClear' display wrong duration.

This will add Duration parameter to `crate::state::State::Done*`
variants and uses it to display duration if curret state of the progress
bar is one of the Done states.

Fixes console-rs#557
Change 1: More compact (and readable) pattern match for
ProgressState.duration() method.

Change 2: Refactor unidiomatic custom test specific constructor to
Copy link
Member

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please squash all your commits.

@djc djc merged commit bd1f3fb into console-rs:main Nov 18, 2025
11 checks passed
@djc
Copy link
Member

djc commented Nov 18, 2025

Thanks!

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.

Duration becomes 0 after calling finish()

2 participants