Skip to content

Commit

Permalink
Merge pull request #1297 from xlaech/FixDinVisualModeBug
Browse files Browse the repository at this point in the history
D in visual mode behaves like d
  • Loading branch information
johnfn authored Feb 15, 2017
2 parents 8140e4f + 47dfca6 commit 2753942
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/actions/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1869,6 +1869,10 @@ export class DeleteOperatorVisual extends BaseOperator {
public modes = [ModeName.Visual, ModeName.VisualLine];

public async run(vimState: VimState, start: Position, end: Position): Promise<VimState> {
// ensures linewise deletion when in visual mode
// see special case in DeleteOperator.delete()
vimState.currentRegisterMode = RegisterMode.LineWise;

return await new DeleteOperator(this.multicursorIndex).run(vimState, start, end);
}
}
Expand Down
31 changes: 25 additions & 6 deletions test/mode/modeVisual.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ suite("Mode Visual", () => {
});

newTest({
title: "Can handle H key",
start: ['1', '2', '|3', '4', '5'],
keysPressed: 'vH',
end: ['|1', '2', '3', '4', '5']
});
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(""));
Expand Down Expand Up @@ -472,7 +472,7 @@ suite("Mode Visual", () => {
});

newTest({
title: "Can handle 'Y' in visual mode" ,
title: "Can handle 'Y' in visual mode",
start: ['one', '|two'],
keysPressed: 'vwYP',
end: ['one', '|two', 'two'],
Expand Down Expand Up @@ -639,4 +639,23 @@ suite("Mode Visual", () => {
end: ["tes|est"],
endMode: ModeName.Normal
});

suite("D command will remove all selected lines", () => {
newTest({
title: "D deletes all selected lines",
start: ["first line", "test| line1", "test line2", "second line"],
keysPressed: "vjD",
end: ["first line", "|second line"],
endMode: ModeName.Normal
});

newTest({
title: "D deletes the current line",
start: ["first line", "test| line1", "second line"],
keysPressed: "vlllD",
end: ["first line", "|second line"],
endMode: ModeName.Normal
});

});
});

0 comments on commit 2753942

Please sign in to comment.