Skip to content

Commit

Permalink
Fix misplaced cursor after VV (#4594)
Browse files Browse the repository at this point in the history
It should go to the column it started at before visual line mode
Fixes #4593
  • Loading branch information
ldm0 committed Feb 26, 2020
1 parent 38b49c5 commit 11073ad
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/actions/commands/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2364,6 +2364,12 @@ class CommandExitVisualLineMode extends BaseCommand {
keys = ['V'];

public async exec(position: Position, vimState: VimState): Promise<VimState> {
if (vimState.visualLineStartColumn !== undefined) {
vimState.cursorStopPosition = vimState.cursorStopPosition.withColumn(
vimState.visualLineStartColumn
);
}

await vimState.setCurrentMode(Mode.Normal);

return vimState;
Expand Down
7 changes: 7 additions & 0 deletions test/mode/modeVisualLine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,4 +485,11 @@ suite('Mode Visual Line', () => {
keysPressed: 'Vj<Esc>',
end: ['rocinante', 'nauvoo', 'anu|bis', 'canterbury'],
});

newTest({
title: 'Exiting via `VV` returns cursor to original column',
start: ['rocinante', 'nau|voo', 'anubis', 'canterbury'],
keysPressed: 'VjV',
end: ['rocinante', 'nauvoo', 'anu|bis', 'canterbury'],
});
});

0 comments on commit 11073ad

Please sign in to comment.