Skip to content

Commit

Permalink
fix #922 (#960)
Browse files Browse the repository at this point in the history
  • Loading branch information
rebornix authored Oct 21, 2016
1 parent 321fd33 commit c58f7af
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/actions/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2153,9 +2153,16 @@ export class PutCommandVisual extends BaseCommand {
canBePrefixedWithDot = true;

public async exec(position: Position, vimState: VimState, after: boolean = false): Promise<VimState> {
const result = await new DeleteOperator().run(vimState, vimState.cursorStartPosition, vimState.cursorPosition, false);
let start = vimState.cursorStartPosition;
let end = vimState.cursorPosition;

return await new PutCommand().exec(vimState.cursorStartPosition, result, true);
if (start.isAfter(end)) {
[start, end] = [end, start];
}

const result = await new DeleteOperator().run(vimState, start, end, false);

return await new PutCommand().exec(start, result, true);
}

// TODO - execWithCount
Expand Down
7 changes: 7 additions & 0 deletions test/mode/modeNormal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,13 @@ suite("Mode Normal", () => {
end: ["abc abc |dhi"]
});

newTest({
title: "can handle p with selection",
start: ["one", "two", "|three"],
keysPressed: "yykVkp",
end: ["|three", "three"]
});

newTest({
title: "can handle P with selection",
start: ["|abc def ghi"],
Expand Down

0 comments on commit c58f7af

Please sign in to comment.