-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 jump_backwards behaviour when jumplist is at capacity #10968
Fix jump_backwards behaviour when jumplist is at capacity #10968
Conversation
2285936
to
12f8df1
Compare
Realised that tests are failing - away from my laptop but will fix when I can |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for opening this up! I've seen this bug before but couldn't figure out how to reproduce the behavior.
As you note in a comment in backwards
, the issue is that we're using current
as a sort of pointer and when we pop items from the front, the index of our "current" item changes. The fix for this I believe is smaller than what you have at the moment here: in backward
we can make current
mut
and subtract the number of items we will remove in push
(self.jumps.len() - JUMP_LIST_CAPACITY + 1
) in the if self.current == self.jumps.len()
block.
Thank you for taking a look! Is it not preferable to update Also, I know that the |
8f57e9c
to
381660c
Compare
Line 66 in dbacaad
The current changes to |
Ah I see, you're right - thanks for explaining. I've removed the changes from |
1fe288e
to
f2721f2
Compare
f2721f2
to
e3b9c1f
Compare
…or#10968) * Fix jump_backwards behaviour when jumplist is at capacity * Decrement self.current while popping from front * Fix issue with conflicting updates to self.current * Realised that truncate is intentional * Use saturating_sub when decrementing current * Fix naming of previous jump, and remove unneeded comment change * Remove unnecessary changes in push * Return num elements removed from front, and use in backward method * Hide num_removed from public interface and tidy up jump location check
…or#10968) * Fix jump_backwards behaviour when jumplist is at capacity * Decrement self.current while popping from front * Fix issue with conflicting updates to self.current * Realised that truncate is intentional * Use saturating_sub when decrementing current * Fix naming of previous jump, and remove unneeded comment change * Remove unnecessary changes in push * Return num elements removed from front, and use in backward method * Hide num_removed from public interface and tidy up jump location check
This PR resolves some issues with the jumplist when the capacity is reached. In particular:
current
position in the jumplist if elements are removed from the front: if an element in the jumplist shifts backwards then the index pointing to that element should shift backwards with it.Fixes #10967.