Skip to content

Commit

Permalink
Merge pull request #3409 from VSCodeVim/fix
Browse files Browse the repository at this point in the history
fix: closes #3157
  • Loading branch information
jpoon authored Jan 23, 2019
2 parents 3bb8ea9 + 270889e commit 8e9d827
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 28 deletions.
2 changes: 1 addition & 1 deletion extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
30 changes: 10 additions & 20 deletions src/mode/modeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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.
*/
Expand All @@ -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;
}

Expand Down Expand Up @@ -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 });
}
}

Expand Down Expand Up @@ -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
Expand Down
8 changes: 1 addition & 7 deletions src/state/vimState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export class VimState implements vscode.Disposable {
*/
public lastVisualSelectionStart: Position;
public lastVisualSelectionEnd: Position;

/**
* Was the previous mouse click past EOL
*/
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 8e9d827

Please sign in to comment.