Make 'gv' work with selection by mouse (and command) (#8965)

Fixes #8913
This commit is contained in:
Yida Zhang 2024-04-06 19:41:01 -04:00 committed by GitHub
parent 6ab9def5a6
commit 8fba985b5f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -258,6 +258,13 @@ export class ModeHandler implements vscode.Disposable, IModeHandler {
this.vimState.cursorStopPosition = selection.active;
this.vimState.cursorStartPosition = selection.anchor;
await this.updateView({ drawSelection: false, revealRange: false });
// Store selection for commands like gv
this.vimState.lastVisualSelection = {
mode: this.vimState.currentMode,
start: this.vimState.cursorStartPosition,
end: this.vimState.cursorStopPosition,
};
return;
} else if (!selection.active.isEqual(selection.anchor)) {
Logger.trace('Creating Visual Selection from command!');
@ -265,6 +272,13 @@ export class ModeHandler implements vscode.Disposable, IModeHandler {
this.vimState.cursorStartPosition = selection.anchor;
await this.setCurrentMode(Mode.Visual);
await this.updateView({ drawSelection: false, revealRange: false });
// Store selection for commands like gv
this.vimState.lastVisualSelection = {
mode: Mode.Visual,
start: this.vimState.cursorStartPosition,
end: this.vimState.cursorStopPosition,
};
return;
}
}
@ -397,6 +411,14 @@ export class ModeHandler implements vscode.Disposable, IModeHandler {
await this.setCurrentMode(Mode.Normal);
}
if (isVisualMode(this.vimState.currentMode)) {
// Store selection for commands like gv
this.vimState.lastVisualSelection = {
mode: this.vimState.currentMode,
start: this.vimState.cursorStartPosition,
end: this.vimState.cursorStopPosition,
};
}
void this.updateView({ drawSelection: toDraw, revealRange: false });
}
}