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 arrow navigation to EOL while in insert #838

Merged
merged 3 commits into from
Oct 5, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/mode/modeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,13 @@ export class ModeHandler implements vscode.Disposable {
var newPosition = new Position(selection.active.line, selection.active.character);

if (newPosition.character >= newPosition.getLineEnd().character) {
newPosition = new Position(newPosition.line, Math.max(newPosition.getLineEnd().character - 1, 0));
if (this._vimState.currentMode === ModeName.Insert) {
// This lets you use arrow keys to move to the end of the line
newPosition = new Position(newPosition.line, Math.max(newPosition.getLineEnd().character, 0));
Copy link
Member

@johnfn johnfn Oct 5, 2016

Choose a reason for hiding this comment

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

Is this necessary? The position will already be bounded between 0 and the length of the line anyways.

Copy link
Member Author

Choose a reason for hiding this comment

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

Where will it be bounded?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah I see, let me try an adjustment

} else {
// This prevents you from mouse clicking past the EOL
newPosition = new Position(newPosition.line, Math.max(newPosition.getLineEnd().character - 1, 0));
}
}

this._vimState.cursorPosition = newPosition;
Expand Down