Skip to content

Commit

Permalink
Merge pull request #1567 from xconverge/add-blackhole-register
Browse files Browse the repository at this point in the history
fixes #1357
  • Loading branch information
xconverge authored Apr 25, 2017
2 parents a725d0d + 558686e commit f3ad12c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/register/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class Register {
'.': { text: "", registerMode: RegisterMode.CharacterWise, isClipboardRegister: false },
'*': { text: "", registerMode: RegisterMode.CharacterWise, isClipboardRegister: true },
'+': { text: "", registerMode: RegisterMode.CharacterWise, isClipboardRegister: true },
'_': { text: "", registerMode: RegisterMode.CharacterWise, isClipboardRegister: false },
'0': { text: "", registerMode: RegisterMode.CharacterWise, isClipboardRegister: false },
'1': { text: "", registerMode: RegisterMode.CharacterWise, isClipboardRegister: false },
'2': { text: "", registerMode: RegisterMode.CharacterWise, isClipboardRegister: false },
Expand All @@ -50,6 +51,9 @@ export class Register {
'9': { text: "", registerMode: RegisterMode.CharacterWise, isClipboardRegister: false }
};

public static isBlackHoleRegister(registerName: string): boolean {
return (registerName === "_");
}

public static isClipboardRegister(registerName: string): boolean {
const register = Register.registers[registerName];
Expand Down Expand Up @@ -90,6 +94,10 @@ export class Register {
throw new Error(`Invalid register ${register}`);
}

if (Register.isBlackHoleRegister(register)) {
return;
}

if (vimState.isMultiCursor) {
if (Register.isValidUppercaseRegister(register)) {
Register.appendMulticursorRegister(content, register, vimState, multicursorIndex as number);
Expand Down Expand Up @@ -243,6 +251,10 @@ export class Register {
util.clipboardCopy(content.toString());
}

if (Register.isBlackHoleRegister(register)) {
return;
}

Register.registers[register] = {
text : content,
registerMode : registerMode || RegisterMode.FigureItOutFromCurrentMode,
Expand Down
7 changes: 7 additions & 0 deletions test/register/register.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ suite("register", () => {
end: ["one", "two", "one", "|two"],
});

newTest({
title: "Can use black hole register",
start: ['|asdf', "qwer"],
keysPressed: 'yyj"_ddkp',
end: ["asdf", "|asdf"],
});

test("System clipboard works with chinese characters", async () => {
const testString = '你好';
util.clipboardCopy(testString);
Expand Down

0 comments on commit f3ad12c

Please sign in to comment.