From a089e45bec7846c6b8cd06b4c9259c4dc334f2e9 Mon Sep 17 00:00:00 2001 From: Sven Efftinge Date: Thu, 30 Jan 2020 18:01:34 +0000 Subject: [PATCH] [core] don't let disabled bindings shadow enabled ones bindings contributed from VS Code extensions do currently always shadow bindings default bindings, no matter they are enabled or not. Signed-off-by: Sven Efftinge --- packages/core/src/browser/keybinding.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/core/src/browser/keybinding.ts b/packages/core/src/browser/keybinding.ts index 536208dd44e33..463cd1e0263da 100644 --- a/packages/core/src/browser/keybinding.ts +++ b/packages/core/src/browser/keybinding.ts @@ -418,17 +418,18 @@ export class KeybindingRegistry { * The lists are sorted by priority (see #sortKeybindingsByPriority). * * @param keySequence The key sequence for which we are looking for keybindings. + * @param event The source keyboard event. */ - getKeybindingsForKeySequence(keySequence: KeySequence): KeybindingRegistry.KeybindingsResult { + getKeybindingsForKeySequence(keySequence: KeySequence, event?: KeyboardEvent): KeybindingRegistry.KeybindingsResult { const result = new KeybindingRegistry.KeybindingsResult(); for (let scope = KeybindingScope.END; --scope >= KeybindingScope.DEFAULT;) { const matches = this.getKeySequenceCollisions(this.keymaps[scope], keySequence); matches.full = matches.full.filter( - binding => this.getKeybindingCollisions(result.full, binding).full.length === 0); + binding => (!event || this.isEnabled(binding, event)) && this.getKeybindingCollisions(result.full, binding).full.length === 0); matches.partial = matches.partial.filter( - binding => this.getKeybindingCollisions(result.partial, binding).partial.length === 0); + binding => (!event || this.isEnabled(binding, event)) && this.getKeybindingCollisions(result.partial, binding).partial.length === 0); if (scope === KeybindingScope.DEFAULT_OVERRIDING) { matches.full.reverse(); @@ -590,7 +591,7 @@ export class KeybindingRegistry { this.keyboardLayoutService.validateKeyCode(keyCode); this.keySequence.push(keyCode); - const bindings = this.getKeybindingsForKeySequence(this.keySequence); + const bindings = this.getKeybindingsForKeySequence(this.keySequence, event); const full = bindings.full.find(binding => this.isEnabled(binding, event)); const partial = bindings.partial.find(binding => (!full || binding.scope! > full.scope!) && this.isEnabled(binding, event)); if (partial) {