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 |
the-mikedavis
left a comment
There was a problem hiding this comment.
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:
currentposition 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.