From e0929f7192666df6f038c3935fc74622c4e7675e Mon Sep 17 00:00:00 2001 From: teslae1 Date: Sat, 3 Jan 2026 19:00:37 +0100 Subject: [PATCH 1/2] added revert to normal mode in case of bad sequence of selectionchange events --- src/mode/modeHandler.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/mode/modeHandler.ts b/src/mode/modeHandler.ts index 2b12abfd02b..e7e6bf7b812 100644 --- a/src/mode/modeHandler.ts +++ b/src/mode/modeHandler.ts @@ -252,6 +252,24 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { // a command, so we need to update our start and stop positions. This is where commands // like 'editor.action.smartSelect.grow' are handled. if (this.vimState.currentMode === Mode.Visual) { + const isEol = + e.textEditor.document && + e.textEditor.document.lineAt(selection.active.line).text.length === + selection.active.character; + const lastSelection = this.vimState.lastVisualSelection; + const previousVisualSelectionIsFromLastCharToEol = + lastSelection && + lastSelection.start.character === selection.active.character - 1 && + lastSelection.end.character === selection.active.character; + const visualModeWasEnteredByPreviousSelectionChangeAndShouldNotHaveBeen = + isEol && previousVisualSelectionIsFromLastCharToEol; + if (visualModeWasEnteredByPreviousSelectionChangeAndShouldNotHaveBeen) { + // Fixes mouseclick at eol when normal mode sometimes triggers + // visual mode. Issue https://github.com/VSCodeVim/Vim/issues/9887 + await this.setCurrentMode(Mode.Normal); + return; + } + Logger.trace('Updating Visual Selection!'); this.vimState.cursor = Cursor.fromSelection(selection); this.updateView({ drawSelection: false, revealRange: false }); From 253f9024f4bc2ebaa31b3808b24dcb901f80cd27 Mon Sep 17 00:00:00 2001 From: teslae1 <58149524+teslae1@users.noreply.github.com> Date: Sun, 4 Jan 2026 12:09:44 +0100 Subject: [PATCH 2/2] Update src/mode/modeHandler.ts Co-authored-by: Jason Fields --- src/mode/modeHandler.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/mode/modeHandler.ts b/src/mode/modeHandler.ts index e7e6bf7b812..1995d43b8a6 100644 --- a/src/mode/modeHandler.ts +++ b/src/mode/modeHandler.ts @@ -253,8 +253,7 @@ export class ModeHandler implements vscode.Disposable, IModeHandler { // like 'editor.action.smartSelect.grow' are handled. if (this.vimState.currentMode === Mode.Visual) { const isEol = - e.textEditor.document && - e.textEditor.document.lineAt(selection.active.line).text.length === + e.textEditor.document?.lineAt(selection.active.line).text.length === selection.active.character; const lastSelection = this.vimState.lastVisualSelection; const previousVisualSelectionIsFromLastCharToEol =