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

Ensure command handler doesn't index out of bounds when at end of file #59302

Merged
merged 3 commits into from
Feb 7, 2022

Conversation

CyrusNajmabadi
Copy link
Member

No description provided.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner February 4, 2022 23:29
@@ -47,6 +47,9 @@ public bool ExecuteCommand(ReturnKeyCommandArgs args, CommandExecutionContext co

var position = caret.Value.Position;
var currentSnapshot = subjectBuffer.CurrentSnapshot;
if (position >= currentSnapshot.Length)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this happen because of virtual space? Otherwise how can the position extend beyond the document?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

caret at the end of the file will be at snapshot.Length. it is after the last actual character.

@CyrusNajmabadi CyrusNajmabadi merged commit c49cfb3 into dotnet:main Feb 7, 2022
@ghost ghost added this to the Next milestone Feb 7, 2022
@CyrusNajmabadi CyrusNajmabadi deleted the outOfBoundsCheck branch February 7, 2022 06:02
@RikkiGibson RikkiGibson modified the milestones: Next, 17.2.P2 Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants