Skip to content

Commit 205b147

Browse files
committed
Actually fix the clipboard register this time. Refs #9821.
1 parent cc58352 commit 205b147

File tree

3 files changed

+24
-19
lines changed

3 files changed

+24
-19
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Change Log
22

3-
## [v1.32.1](https://github.com/vscodevim/vim/tree/v1.32.1) (2025-11-8)
3+
## [v1.32.1](https://github.com/vscodevim/vim/tree/v1.32.1) (2025-11-9)
44

55
### Fixed
66

src/register/register.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,10 @@ export class Register {
282282
registerMode: RegisterMode.CharacterWise,
283283
};
284284
Register.registers.set(register, [registerContent]);
285-
return registerContent;
286285
}
287286
}
288-
return Register.getSync(register, multicursorIndex);
287+
288+
return Register._get(register, multicursorIndex);
289289
}
290290

291291
/**
@@ -294,25 +294,27 @@ export class Register {
294294
* NOTE: The clipboard register is silently converted to the unnamed register
295295
*/
296296
public static getSync(register: string, multicursorIndex = 0): IRegisterContent | undefined {
297-
if (!Register.isValidRegister(register)) {
298-
throw new Error(`Invalid register ${register}`);
299-
}
300-
301297
if (Register.isClipboardRegister(register)) {
302298
register = '"';
303299
}
304300

301+
return Register._get(register, multicursorIndex);
302+
}
303+
304+
private static _get(register: string, multicursorIndex: number): IRegisterContent | undefined {
305+
if (!Register.isValidRegister(register)) {
306+
throw new Error(`Invalid register ${register}`);
307+
}
308+
305309
register = register.toLowerCase();
306310

307311
const contentByCursor = Register.registers.get(register);
308-
309-
// Default to the first cursor.
310-
if (contentByCursor?.[multicursorIndex] === undefined) {
311-
// If multicursorIndex is too high, try the first cursor
312-
multicursorIndex = 0;
312+
if (contentByCursor === undefined) {
313+
return undefined;
313314
}
314315

315-
return contentByCursor?.[multicursorIndex];
316+
// Default to first cursor if the requested multicursor index doesn't exist
317+
return contentByCursor[multicursorIndex] ?? contentByCursor[0];
316318
}
317319

318320
public static has(register: string): boolean {

test/mode/modeNormal.test.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,15 @@ suite('Mode Normal', () => {
120120
end: ['one', '|two'],
121121
});
122122

123-
newTest({
124-
title: 'Can handle ddp',
125-
start: ['|one', 'two'],
126-
keysPressed: 'ddp',
127-
end: ['two', '|one'],
128-
});
123+
for (const useSystemClipboard of [true, false]) {
124+
newTest({
125+
title: 'Can handle ddp',
126+
config: { useSystemClipboard },
127+
start: ['|one', 'two'],
128+
keysPressed: 'ddp',
129+
end: ['two', '|one'],
130+
});
131+
}
129132

130133
newTest({
131134
title: "Can handle 'de'",

0 commit comments

Comments
 (0)