Skip to content

Commit fd0c08e

Browse files
authored
fix: Copy shortcuts before returning them (#9109)
1 parent 38df7c8 commit fd0c08e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

core/shortcut_registry.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,9 @@ export class ShortcutRegistry {
278278
* Undefined if no shortcuts exist.
279279
*/
280280
getShortcutNamesByKeyCode(keyCode: string): string[] | undefined {
281-
return this.keyMap.get(keyCode) || [];
281+
// Copy the list of shortcuts in case one of them unregisters itself
282+
// in its callback.
283+
return this.keyMap.get(keyCode)?.slice() || [];
282284
}
283285

284286
/**

0 commit comments

Comments
 (0)