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

Fixes #36544. #36578

Merged
merged 1 commit into from Oct 20, 2017
Merged

Fixes #36544. #36578

merged 1 commit into from Oct 20, 2017

Conversation

brandonbloom
Copy link
Contributor

This was definitely a bug in my "Go Last" implementation, but it was only exposed by using 499086d (and/also 273dbee) which made more aggressive use of the addOrReplaceInStack method.

The problem is that when the navigation stack is full, the array is shifted over and indexes are patched up. This can result with a lastIndex that exceeds the length of the array, since setIndex was being called twice during the patch up with inconsistent array lengths. The fix is to only call setIndex once, after the length is corrected. This also fixes a bug in "Go Last" where the "last" position is wrong if it's not this.stack.length - 1 after the history buffer fills up. To fix that, we slide the lastIndex over along with the array unshift. If the last index falls off the left side of the array, it will be -1, which is already handled by last() to fallback to the behavior of back().

@bpasero bpasero added this to the October 2017 milestone Oct 20, 2017
@bpasero bpasero merged commit 8ce940f into microsoft:master Oct 20, 2017
@github-actions github-actions bot locked and limited conversation to collaborators Mar 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants