diff --git a/src/actions/actions.ts b/src/actions/actions.ts index 5b4ac4e9b76..04905f6ec26 100644 --- a/src/actions/actions.ts +++ b/src/actions/actions.ts @@ -2427,6 +2427,10 @@ class CommandDeleteToLineEnd extends BaseCommand { canBeRepeatedWithDot = true; public async exec(position: Position, vimState: VimState): Promise { + if (position.isLineEnd()) { + return vimState; + } + return await new DeleteOperator().run(vimState, position, position.getLineEnd().getLeft()); } } diff --git a/test/mode/normalModeTests/commands.test.ts b/test/mode/normalModeTests/commands.test.ts index 4690f9f8e88..cdccb5e11b0 100644 --- a/test/mode/normalModeTests/commands.test.ts +++ b/test/mode/normalModeTests/commands.test.ts @@ -105,6 +105,13 @@ suite("Mode Normal", () => { end: ['t|e'], }); + newTest({ + title: "Can handle 'D' on empty lines", + start: ['text', '|', 'text'], + keysPressed: 'D', + end: ['text', '|', 'text'] + }); + newTest({ title: "Can handle 'DD'", start: ['tex|t'],