From dfe4cbfac7966dcb13ce41aaee3a8ca203075df7 Mon Sep 17 00:00:00 2001 From: xconverge Date: Tue, 25 Oct 2016 19:53:52 -0700 Subject: [PATCH 1/2] Fix for visual line behaving funky when going from bottom up --- src/mode/modeHandler.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/mode/modeHandler.ts b/src/mode/modeHandler.ts index 65cda981674..b6d37257c60 100644 --- a/src/mode/modeHandler.ts +++ b/src/mode/modeHandler.ts @@ -1362,13 +1362,19 @@ export class ModeHandler implements vscode.Disposable { selections = [ new vscode.Selection(start, stop) ]; } else if (vimState.currentMode === ModeName.VisualLine) { - selections = [ new vscode.Selection( + selections = [new vscode.Selection( Position.EarlierOf(start, stop).getLineBegin(), Position.LaterOf(start, stop).getLineEnd() - ) ]; - vimState.cursorStartPosition = selections[0].start as Position; - vimState.cursorPosition = selections[0].end as Position; + )]; + // Maintain cursor position based on which direction the selection is going + if (start.line <= stop.line) { + vimState.cursorStartPosition = selections[0].start as Position; + vimState.cursorPosition = selections[0].end as Position; + } else { + vimState.cursorStartPosition = selections[0].end as Position; + vimState.cursorPosition = selections[0].start as Position; + } } else if (vimState.currentMode === ModeName.VisualBlock) { selections = []; From 2614dbf3392af42973cb2062d0cce7cb4663cde9 Mon Sep 17 00:00:00 2001 From: xconverge Date: Tue, 25 Oct 2016 19:57:34 -0700 Subject: [PATCH 2/2] Add test for visual line replace from the bottom up --- test/mode/modeVisualLine.test.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/mode/modeVisualLine.test.ts b/test/mode/modeVisualLine.test.ts index f6ce347abb3..453cc361aa1 100644 --- a/test/mode/modeVisualLine.test.ts +++ b/test/mode/modeVisualLine.test.ts @@ -308,6 +308,14 @@ suite("Mode Visual", () => { end: ["|11111111111111111111111", "11111111111111111111111"], endMode: ModeName.Normal }); + + newTestOnly({ + title: "Can do a multi visual line replace from the bottom up", + start: ["test", "test", "test", "|test", "test"], + keysPressed: "Vkkr1", + end: ["test", "|1111", "1111", "1111", "test"], + endMode: ModeName.Normal + }); }); });