diff --git a/src/actions/actions.ts b/src/actions/actions.ts index 32c49421d3d..4d5df7dc829 100644 --- a/src/actions/actions.ts +++ b/src/actions/actions.ts @@ -837,9 +837,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 @@ -2756,12 +2758,14 @@ class ActionChangeInVisualBlockMode extends BaseCommand { const deleteOperator = new DeleteOperator(); 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; vimState.recordedState.visualBlockInsertionType = VisualBlockInsertionType.Insert; + vimState.cursorPosition = vimState.cursorPosition.getLeft(); + return vimState; } } @@ -2856,7 +2860,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; }