From 9cad61aa81964a18d94200d819ed6ac3751ab293 Mon Sep 17 00:00:00 2001 From: Aaron Dodson Date: Thu, 29 May 2025 09:53:01 -0700 Subject: [PATCH] fix: Copy shortcuts before returning them --- core/shortcut_registry.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/shortcut_registry.ts b/core/shortcut_registry.ts index 8a276c3d51c..f40149db816 100644 --- a/core/shortcut_registry.ts +++ b/core/shortcut_registry.ts @@ -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() || []; } /**