fix: Copy shortcuts before returning them (#9109)

This commit is contained in:
Aaron Dodson
2025-05-29 09:59:45 -07:00
committed by GitHub
parent 38df7c8776
commit fd0c08e950

View File

@@ -278,7 +278,9 @@ export class ShortcutRegistry {
* Undefined if no shortcuts exist.
*/
getShortcutNamesByKeyCode(keyCode: string): string[] | undefined {
return this.keyMap.get(keyCode) || [];
// Copy the list of shortcuts in case one of them unregisters itself
// in its callback.
return this.keyMap.get(keyCode)?.slice() || [];
}
/**