From b193c22324f71b85c36210e24586e8f7f3ddabe1 Mon Sep 17 00:00:00 2001 From: Sean Kelly Date: Wed, 5 Oct 2016 12:44:27 -0700 Subject: [PATCH] fixes #784 (#814) * fixes #784 * Cleaned up implementation of fix slightly --- src/actions/actions.ts | 14 ++++++++++---- test/mode/modeVisual.test.ts | 7 +++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/actions/actions.ts b/src/actions/actions.ts index 5b5fe9caf65..1d833febbf5 100644 --- a/src/actions/actions.ts +++ b/src/actions/actions.ts @@ -2619,10 +2619,16 @@ abstract class MoveByScreenLine extends BaseMovement { * cursorMove command is handling the selection for us. * So we are not following our design principal (do no real movement inside an action) here. */ - return { - start: Position.FromVSCodePosition(vscode.window.activeTextEditor.selection.start), - stop: Position.FromVSCodePosition(vscode.window.activeTextEditor.selection.end) - }; + + let start = Position.FromVSCodePosition(vscode.window.activeTextEditor.selection.start); + let stop = Position.FromVSCodePosition(vscode.window.activeTextEditor.selection.end); + + // We want to swap the cursor start stop positions based on which direction we are moving, up or down + if (start.line < position.line) { + [start, stop] = [stop, start]; + } + + return { start, stop }; } } diff --git a/test/mode/modeVisual.test.ts b/test/mode/modeVisual.test.ts index 0a907d55ab5..c8aefc2c17d 100644 --- a/test/mode/modeVisual.test.ts +++ b/test/mode/modeVisual.test.ts @@ -126,6 +126,13 @@ suite("Mode Visual", () => { assertEqualLines(["wo three"]); }); + newTest({ + title: "Can handle H key", + start: ['1', '2', '|3', '4', '5'], + keysPressed: 'vH', + end: ['|1', '2', '3', '4', '5'] + }); + test("handles case where we delete over a newline", async () => { await modeHandler.handleMultipleKeyEvents("ione two\n\nthree four".split("")); await modeHandler.handleMultipleKeyEvents([