Skip to content

Fix AtomicPosition::reset storing wrong value#650

Merged
djc merged 2 commits intoconsole-rs:mainfrom
TheJokr:fix-position-reset
Jul 12, 2024
Merged

Fix AtomicPosition::reset storing wrong value#650
djc merged 2 commits intoconsole-rs:mainfrom
TheJokr:fix-position-reset

Conversation

@TheJokr
Copy link
Copy Markdown
Contributor

@TheJokr TheJokr commented Jul 11, 2024

AtomicPosition::allow interprets self.prev as a number of nanoseconds since self.start, but AtomicPosition::reset instead stored a number of milliseconds in there. This is a bug, albeit without significant consequences.

I reckon the bug got introduced because the comments are worded a bit ambiguously, so I cleared those up and added a regression test for the future.

TheJokr added 2 commits July 11, 2024 21:23
Resetting AtomicPosition incorrectly stores the elapsed time in ms
inside `prev`, but AtomicPosition::allow expects this value to be in ns.
The code actually expects this value to be in ns. I reckon the bug got
introduced because the comments are worded a bit ambiguously, so I also
cleared those up.
Copy link
Copy Markdown
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.

Awesome, thanks! How did you find this?

@TheJokr
Copy link
Copy Markdown
Contributor Author

TheJokr commented Jul 11, 2024

I was checking out how often tick() is scheduled by ProgressBar::inc(), so I read through that part of the code and was confused by the comments 😅 And then I noticed the inconsistency with the reset() function, which was right below.

@djc djc merged commit 5295317 into console-rs:main Jul 12, 2024
@TheJokr TheJokr deleted the fix-position-reset branch July 12, 2024 13:02
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.

2 participants