@@ -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 {
0 commit comments