diff --git a/src/register/register.ts b/src/register/register.ts index 43757a0cda9..4a9344e2348 100644 --- a/src/register/register.ts +++ b/src/register/register.ts @@ -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 }, @@ -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]; @@ -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); @@ -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, diff --git a/test/register/register.test.ts b/test/register/register.test.ts index 706ee59bce9..81a47aa2906 100644 --- a/test/register/register.test.ts +++ b/test/register/register.test.ts @@ -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);