Skip to content

Commit

Permalink
multiline yank writes to 0 register; fixes VSCodeVim#1214
Browse files Browse the repository at this point in the history
  • Loading branch information
jkillian committed Oct 2, 2018
1 parent bd153ad commit afbfccc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/register/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,7 @@ export class Register {
*/
private static processNumberedRegister(content: RegisterContent, vimState: VimState): void {
// Find the BaseOperator of the current actions
const baseOperator = vimState.recordedState.actionsRun.find(value => {
return value instanceof BaseOperator || value instanceof BaseCommand;
});
const baseOperator = vimState.recordedState.operator || vimState.recordedState.command;

if (baseOperator instanceof YankOperator || baseOperator instanceof CommandYankFullLine) {
// 'yank' to 0 only if no register was specified
Expand Down
22 changes: 22 additions & 0 deletions test/register/register.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,28 @@ suite('register', () => {
assertEqualLines(['test2', 'test2', 'test3']);
});

test("Multiline yank stores text in Register '0'", async () => {
modeHandler.vimState.editor = vscode.window.activeTextEditor!;

await modeHandler.handleMultipleKeyEvents('itest1\ntest2\ntest3'.split(''));

await modeHandler.handleMultipleKeyEvents([
'<Esc>',
'g',
'g',
'2',
'y',
'y',
'd',
'd',
'"',
'0',
'P',
]);

assertEqualLines(['test1', 'test2', 'test2', 'test3']);
});

test("Register '1'-'9' stores delete content", async () => {
modeHandler.vimState.editor = vscode.window.activeTextEditor!;

Expand Down

0 comments on commit afbfccc

Please sign in to comment.