From 4f945cd3d2f8d24a74b98c39a4bd9bf680f0afdb Mon Sep 17 00:00:00 2001 From: xconverge Date: Mon, 29 Aug 2016 20:07:43 -0700 Subject: [PATCH 1/4] add .vscode folder to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 2957885e7aa..e3bc8937541 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ node_modules *.vsix *.log testing +.vscode/ From 292426cfe6d35a05675c42a3d55c6e8c8d8b7940 Mon Sep 17 00:00:00 2001 From: xconverge Date: Mon, 29 Aug 2016 21:28:06 -0700 Subject: [PATCH 2/4] fixes #662 --- src/actions/actions.ts | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/actions/actions.ts b/src/actions/actions.ts index 683dd5dc552..34f83f51d6b 100644 --- a/src/actions/actions.ts +++ b/src/actions/actions.ts @@ -846,9 +846,11 @@ export class DeleteOperator extends BaseOperator { // Vim does this weird thing where it allows you to select and delete // the newline character, which it places 1 past the last character // in the line. Here we interpret a character position 1 past the end - // as selecting the newline character. - if (end.character === TextEditor.getLineAt(end).text.length + 1) { - end = end.getDown(0); + // as selecting the newline character. Don't allow this in visual block mode + if (vimState.currentMode !== ModeName.VisualBlock) { + if (end.character === TextEditor.getLineAt(end).text.length + 1) { + end = end.getDown(0); + } } // If we delete linewise to the final line of the document, we expect the line @@ -2685,8 +2687,26 @@ class ActionChangeInVisualBlockMode extends BaseCommand { public async exec(position: Position, vimState: VimState): Promise { const deleteOperator = new DeleteOperator(); + // Check to see number in lines of block + let blockLines = 0; + let blockStart = position; + let blockEnd = position; + for (const {start, end} of Position.IterateLine(vimState)) { + blockStart = start; + blockEnd = end; + blockLines += 1; + } + + // Do a regular visual 'change' if only 1 line of block is selected + if (blockLines < 2) { + await new DeleteOperator().run(vimState, blockStart, blockEnd.getLeft()); + vimState.cursorPosition = vimState.cursorStartPosition; + vimState.currentMode = ModeName.Insert; + return vimState; + } + for (const { start, end } of Position.IterateLine(vimState)) { - await deleteOperator.delete(start, end, vimState.currentMode, vimState.effectiveRegisterMode(), vimState, true); + await deleteOperator.delete(start, end.getLeft(), vimState.currentMode, vimState.effectiveRegisterMode(), vimState, true); } vimState.currentMode = ModeName.VisualBlockInsertMode; @@ -2786,7 +2806,7 @@ class InsertInInsertVisualBlockMode extends BaseCommand { posChange = -1; } else { - await TextEditor.insert(this.keysPressed[0], insertPos.getLeft()); + await TextEditor.insert(this.keysPressed[0], insertPos); posChange = 1; } From cee09f70336c1d8bd0a75714af9d2508e70462d1 Mon Sep 17 00:00:00 2001 From: xconverge Date: Tue, 30 Aug 2016 19:18:13 -0700 Subject: [PATCH 3/4] Fixed wrong cursor position with visual block change command --- src/actions/actions.ts | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/actions/actions.ts b/src/actions/actions.ts index 34f83f51d6b..30f39fce5cb 100644 --- a/src/actions/actions.ts +++ b/src/actions/actions.ts @@ -2687,24 +2687,6 @@ class ActionChangeInVisualBlockMode extends BaseCommand { public async exec(position: Position, vimState: VimState): Promise { const deleteOperator = new DeleteOperator(); - // Check to see number in lines of block - let blockLines = 0; - let blockStart = position; - let blockEnd = position; - for (const {start, end} of Position.IterateLine(vimState)) { - blockStart = start; - blockEnd = end; - blockLines += 1; - } - - // Do a regular visual 'change' if only 1 line of block is selected - if (blockLines < 2) { - await new DeleteOperator().run(vimState, blockStart, blockEnd.getLeft()); - vimState.cursorPosition = vimState.cursorStartPosition; - vimState.currentMode = ModeName.Insert; - return vimState; - } - for (const { start, end } of Position.IterateLine(vimState)) { await deleteOperator.delete(start, end.getLeft(), vimState.currentMode, vimState.effectiveRegisterMode(), vimState, true); } @@ -2712,6 +2694,8 @@ class ActionChangeInVisualBlockMode extends BaseCommand { vimState.currentMode = ModeName.VisualBlockInsertMode; vimState.recordedState.visualBlockInsertionType = VisualBlockInsertionType.Insert; + vimState.cursorPosition = vimState.cursorPosition.getLeft(); + return vimState; } } From 0d102fd1379ed411c605115b117bc3fc92feba42 Mon Sep 17 00:00:00 2001 From: Sean Kelly Date: Tue, 30 Aug 2016 19:46:01 -0700 Subject: [PATCH 4/4] Should not have updated .gitignore.. --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index e3bc8937541..2957885e7aa 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,3 @@ node_modules *.vsix *.log testing -.vscode/