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

Fix AtomicPosition::reset storing wrong value #650

Merged
merged 2 commits into from
Jul 12, 2024

Conversation

TheJokr
Copy link
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
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
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
10 checks passed
@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