From 11073ad38b48bfdabd922969580133e2b5c095fb Mon Sep 17 00:00:00 2001 From: Donough Liu Date: Wed, 26 Feb 2020 14:16:40 +0800 Subject: [PATCH] Fix misplaced cursor after `VV` (#4594) It should go to the column it started at before visual line mode Fixes #4593 --- src/actions/commands/actions.ts | 6 ++++++ test/mode/modeVisualLine.test.ts | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/src/actions/commands/actions.ts b/src/actions/commands/actions.ts index 95c30ff7924..d63573cd5c3 100644 --- a/src/actions/commands/actions.ts +++ b/src/actions/commands/actions.ts @@ -2364,6 +2364,12 @@ class CommandExitVisualLineMode extends BaseCommand { keys = ['V']; public async exec(position: Position, vimState: VimState): Promise { + if (vimState.visualLineStartColumn !== undefined) { + vimState.cursorStopPosition = vimState.cursorStopPosition.withColumn( + vimState.visualLineStartColumn + ); + } + await vimState.setCurrentMode(Mode.Normal); return vimState; diff --git a/test/mode/modeVisualLine.test.ts b/test/mode/modeVisualLine.test.ts index bc0f03ba7de..4ede8146c91 100644 --- a/test/mode/modeVisualLine.test.ts +++ b/test/mode/modeVisualLine.test.ts @@ -485,4 +485,11 @@ suite('Mode Visual Line', () => { keysPressed: 'Vj', 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'], + }); });