From a5f03f84c93aca94e6c24a0bbd8b52928241306d Mon Sep 17 00:00:00 2001 From: Jonah Iden Date: Thu, 20 Jun 2024 13:17:43 +0200 Subject: [PATCH] improved shown keybindings in context menu (#13830) * improved shown keybindings in context menu Signed-off-by: Jonah Iden * small performance improvement Signed-off-by: Jonah Iden --------- Signed-off-by: Jonah Iden --- packages/core/src/browser/menu/browser-menu-plugin.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/core/src/browser/menu/browser-menu-plugin.ts b/packages/core/src/browser/menu/browser-menu-plugin.ts index 931b0719d931e..392c2003eac26 100644 --- a/packages/core/src/browser/menu/browser-menu-plugin.ts +++ b/packages/core/src/browser/menu/browser-menu-plugin.ts @@ -468,9 +468,11 @@ export class MenuCommandRegistry extends PhosphorCommandRegistry { }); const bindings = keybindingRegistry.getKeybindingsForCommand(id); - // Only consider the first keybinding. + // Only consider the first active keybinding. if (bindings.length) { - const binding = bindings[0]; + const binding = bindings.length > 1 ? + bindings.find(b => !b.when || this.services.contextKeyService.match(b.when)) ?? bindings[0] : + bindings[0]; const keys = keybindingRegistry.acceleratorFor(binding, ' ', true); this.addKeyBinding({ command: id,