From 3cd674f440413c6cee9c95c06ec3837ada44b842 Mon Sep 17 00:00:00 2001 From: Horace He Date: Thu, 8 Mar 2018 15:50:21 -0500 Subject: [PATCH 1/2] fix: Readds vimState.lastClickWasPastEOL. Fixes #2404 --- src/mode/modeHandler.ts | 7 ++++--- src/state/vimState.ts | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/mode/modeHandler.ts b/src/mode/modeHandler.ts index 550f24628b9..dacf64be33a 100644 --- a/src/mode/modeHandler.ts +++ b/src/mode/modeHandler.ts @@ -181,7 +181,6 @@ export class ModeHandler implements vscode.Disposable { } let toDraw = false; - let isLastClickPastEol = false; if (selection) { let newPosition = new Position(selection.active.line, selection.active.character); @@ -189,7 +188,7 @@ export class ModeHandler implements vscode.Disposable { // Only check on a click, not a full selection (to prevent clicking past EOL) if (newPosition.character >= newPosition.getLineEnd().character && selection.isEmpty) { if (this.vimState.currentMode !== ModeName.Insert) { - isLastClickPastEol = true; + this.vimState.lastClickWasPastEol = true; // This prevents you from mouse clicking past the EOL newPosition = new Position( @@ -202,6 +201,8 @@ export class ModeHandler implements vscode.Disposable { toDraw = true; } + } else if (selection.isEmpty) { + this.vimState.lastClickWasPastEol = false; } this.vimState.cursorPosition = newPosition; @@ -229,7 +230,7 @@ export class ModeHandler implements vscode.Disposable { } // If we prevented from clicking past eol but it is part of this selection, include the last char - if (isLastClickPastEol) { + if (this.vimState.lastClickWasPastEol) { const newStart = new Position(selection.anchor.line, selection.anchor.character + 1); this.vimState.editor.selection = new vscode.Selection(newStart, selection.end); this.vimState.cursorStartPosition = selectionStart; diff --git a/src/state/vimState.ts b/src/state/vimState.ts index 4e786b9b418..6fff3ff9450 100644 --- a/src/state/vimState.ts +++ b/src/state/vimState.ts @@ -172,6 +172,10 @@ export class VimState implements vscode.Disposable { */ public lastVisualSelectionStart: Position; public lastVisualSelectionEnd: Position; + /** + * Was the previous mouse click past EOL + */ + public lastClickWasPastEol: boolean = false; /** * The mode Vim will be in once this action finishes. From 29f8604d49e0483c9f4dcd3d2d4d1eabada2ced2 Mon Sep 17 00:00:00 2001 From: Horace He Date: Thu, 8 Mar 2018 15:58:41 -0500 Subject: [PATCH 2/2] Added case I missed --- src/mode/modeHandler.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mode/modeHandler.ts b/src/mode/modeHandler.ts index dacf64be33a..6245236a641 100644 --- a/src/mode/modeHandler.ts +++ b/src/mode/modeHandler.ts @@ -234,6 +234,7 @@ export class ModeHandler implements vscode.Disposable { const newStart = new Position(selection.anchor.line, selection.anchor.character + 1); this.vimState.editor.selection = new vscode.Selection(newStart, selection.end); this.vimState.cursorStartPosition = selectionStart; + this.vimState.lastClickWasPastEol = false; } if (