From a167616befb515484d8c2ceaa0974cbcc7bb459a Mon Sep 17 00:00:00 2001 From: xconverge Date: Sat, 17 Dec 2016 11:58:01 -0800 Subject: [PATCH 1/2] fixes #1170 --- src/actions/actions.ts | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/actions/actions.ts b/src/actions/actions.ts index 770e20084f9..e9a5057d3d2 100644 --- a/src/actions/actions.ts +++ b/src/actions/actions.ts @@ -2375,7 +2375,7 @@ class IndentOperatorInVisualModesIsAWeirdSpecialCase extends BaseOperator { @RegisterAction class OutdentOperator extends BaseOperator { - modes = [ModeName.Normal, ModeName.Visual, ModeName.VisualLine]; + modes = [ModeName.Normal]; keys = ["<"]; public async run(vimState: VimState, start: Position, end: Position): Promise { @@ -2383,7 +2383,33 @@ class OutdentOperator extends BaseOperator { await vscode.commands.executeCommand("editor.action.outdentLines"); vimState.currentMode = ModeName.Normal; - vimState.cursorPosition = vimState.cursorStartPosition; + vimState.cursorPosition = start.getFirstLineNonBlankChar(); + + return vimState; + } +} + +/** + * `3<` to outdent a line 3 times in visual mode is actually a bit of a special case. + * + * < is an operator, and generally speaking, you don't run operators multiple times, you run motions multiple times. + * e.g. `d3w` runs `w` 3 times, then runs d once. + * + * Same with literally every other operator motion combination... until `3<`in visual mode + * walked into my life. + */ +@RegisterAction +class OutdentOperatorInVisualModesIsAWeirdSpecialCase extends BaseOperator { + modes = [ModeName.Visual, ModeName.VisualLine]; + keys = ["<"]; + + public async run(vimState: VimState, start: Position, end: Position): Promise { + for (let i = 0; i < (vimState.recordedState.count || 1); i++) { + await vscode.commands.executeCommand("editor.action.outdentLines"); + } + + vimState.currentMode = ModeName.Normal; + vimState.cursorPosition = start.getFirstLineNonBlankChar(); return vimState; } From 94b02e5ba6b24d1d845c10f5410d721a404ed311 Mon Sep 17 00:00:00 2001 From: xconverge Date: Sun, 18 Dec 2016 16:04:49 -0800 Subject: [PATCH 2/2] Shortened comment by pointing to other applicable comment --- src/actions/actions.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/actions/actions.ts b/src/actions/actions.ts index 91bc4488363..6af5cc13efc 100644 --- a/src/actions/actions.ts +++ b/src/actions/actions.ts @@ -2390,13 +2390,7 @@ class OutdentOperator extends BaseOperator { } /** - * `3<` to outdent a line 3 times in visual mode is actually a bit of a special case. - * - * < is an operator, and generally speaking, you don't run operators multiple times, you run motions multiple times. - * e.g. `d3w` runs `w` 3 times, then runs d once. - * - * Same with literally every other operator motion combination... until `3<`in visual mode - * walked into my life. + * See comment for IndentOperatorInVisualModesIsAWeirdSpecialCase */ @RegisterAction class OutdentOperatorInVisualModesIsAWeirdSpecialCase extends BaseOperator {