From 270889e087feb93766ce60db59846f3f2b639bb9 Mon Sep 17 00:00:00 2001 From: Jason Poon Date: Wed, 23 Jan 2019 15:23:57 -0800 Subject: [PATCH] fix: closes #3157 --- extension.ts | 2 +- src/mode/modeHandler.ts | 30 ++++++++++-------------------- src/state/vimState.ts | 8 +------- 3 files changed, 12 insertions(+), 28 deletions(-) diff --git a/extension.ts b/extension.ts index 869d6b36071..5988e4eef29 100644 --- a/extension.ts +++ b/extension.ts @@ -215,7 +215,7 @@ export async function activate(context: vscode.ExtensionContext) { context, vscode.window.onDidChangeTextEditorSelection, async (e: vscode.TextEditorSelectionChangeEvent) => { - const mh = await getAndUpdateModeHandler(true); + const mh = await getAndUpdateModeHandler(); if (mh.vimState.focusChanged) { mh.vimState.focusChanged = false; diff --git a/src/mode/modeHandler.ts b/src/mode/modeHandler.ts index fc1b668be72..319d5117a99 100644 --- a/src/mode/modeHandler.ts +++ b/src/mode/modeHandler.ts @@ -86,7 +86,6 @@ export class ModeHandler implements vscode.Disposable { this.vimState.editor.selection.start ); this.vimState.desiredColumn = this.vimState.cursorPosition.character; - this.vimState.prevSelection = this.vimState.editor.selection; } }, 0); } @@ -123,19 +122,18 @@ export class ModeHandler implements vscode.Disposable { Position.FromVSCodePosition(sel.active) ) ); - await this.updateView(this.vimState); - return; + return this.updateView(this.vimState); } /** * We only trigger our view updating process if it's a mouse selection. - * Otherwise we only update our internal cursor postions accordingly. + * Otherwise we only update our internal cursor positions accordingly. */ if (e.kind !== vscode.TextEditorSelectionChangeKind.Mouse) { if (selection) { if (this.currentMode.isVisualMode) { /** - * In Visual Mode, our `cursorPosition` and `cursorStartPosition` can not refect `active`, + * In Visual Mode, our `cursorPosition` and `cursorStartPosition` can not reflect `active`, * `start`, `end` and `anchor` information in a selection. * See `Fake block cursor with text decoration` section of `updateView` method. */ @@ -152,15 +150,10 @@ export class ModeHandler implements vscode.Disposable { this.vimState.isMultiCursor = false; } - if (this.vimState.prevSelection && this.vimState.prevSelection.isEqual(selection)) { - return; - } - - if (this.vimState.currentMode === ModeName.SearchInProgressMode) { - return; - } - - if (this.vimState.currentMode === ModeName.CommandlineInProgress) { + if ( + this.vimState.currentMode === ModeName.SearchInProgressMode || + this.vimState.currentMode === ModeName.CommandlineInProgress + ) { return; } @@ -230,13 +223,11 @@ export class ModeHandler implements vscode.Disposable { // double click mouse selection causes an extra character to be selected so take one less character } - } else { - if (this.vimState.currentMode !== ModeName.Insert) { - await this.setCurrentMode(ModeName.Normal); - } + } else if (this.vimState.currentMode !== ModeName.Insert) { + await this.setCurrentMode(ModeName.Normal); } - await this.updateView(this.vimState, { drawSelection: toDraw, revealRange: true }); + return this.updateView(this.vimState, { drawSelection: toDraw, revealRange: true }); } } @@ -1273,7 +1264,6 @@ export class ModeHandler implements vscode.Disposable { } } - this.vimState.prevSelection = selections[0]; if ( vimState.recordedState.actionsRun.filter(x => x instanceof DocumentContentChangeAction) .length === 0 diff --git a/src/state/vimState.ts b/src/state/vimState.ts index 497fabab116..048c92bbea4 100644 --- a/src/state/vimState.ts +++ b/src/state/vimState.ts @@ -177,6 +177,7 @@ export class VimState implements vscode.Disposable { */ public lastVisualSelectionStart: Position; public lastVisualSelectionEnd: Position; + /** * Was the previous mouse click past EOL */ @@ -221,13 +222,6 @@ export class VimState implements vscode.Disposable { public recordedMacro = new RecordedState(); - /** - * Programmatically triggering an edit will unfortunately ALSO trigger our mouse update - * function. We use this variable to determine if the update function was triggered - * by us or by a mouse action. - */ - public prevSelection: vscode.Selection; - public nvim: NeovimWrapper; private _inputMethodSwitcher: InputMethodSwitcher;