Fix gj and gk in visual mode

Our stupid representation of visual selections has bitten our ass once again.
Fixes #4544
This commit is contained in:
Jason Fields 2020-07-25 17:08:25 -04:00
parent 35d06e6780
commit 3f53243192

View File

@ -53,6 +53,17 @@ abstract class MoveByScreenLine extends BaseMovement {
vimState: VimState,
count: number
): Promise<Position | IMovement> {
if (
vimState.currentMode === Mode.Visual &&
vimState.cursorStopPosition.isAfterOrEqual(vimState.cursorStartPosition)
) {
// The selection is on the right side of the cursor, while our representation considers the cursor to be the left edge
vimState.editor.selection = new vscode.Selection(
vimState.cursorStartPosition,
vimState.cursorStopPosition
);
}
await vscode.commands.executeCommand('cursorMove', {
to: this.movementType,
select: vimState.currentMode !== Mode.Normal,