diff --git a/src/vs/platform/keybinding/common/keybindingResolver.ts b/src/vs/platform/keybinding/common/keybindingResolver.ts index 722f736923f45d3ab75264f2ff99152b4e46ecab..ec6b0cbfbf35b429f1293049fcdce9c37ab83743 100644 --- a/src/vs/platform/keybinding/common/keybindingResolver.ts +++ b/src/vs/platform/keybinding/common/keybindingResolver.ts @@ -36,6 +36,7 @@ export class NormalizedKeybindingItem { command: string; when: KbExpr; isDefault: boolean; + actualCommand: string; public static fromKeybindingItem(source:IKeybindingItem, isDefault:boolean): NormalizedKeybindingItem { let when: KbExpr = null; @@ -48,6 +49,7 @@ export class NormalizedKeybindingItem { constructor(keybinding: number, command: string, when: KbExpr, isDefault: boolean) { this.keybinding = keybinding; this.command = command; + this.actualCommand = this.command ? this.command.replace(/^\^/, '') : this.command; this.when = when; this.isDefault = isDefault; } @@ -115,7 +117,7 @@ export class KeybindingResolver { } private static _isTargetedForRemoval(defaultKb:NormalizedKeybindingItem, keybinding:number, command:string, when:KbExpr): boolean { - if (defaultKb.command !== command) { + if (defaultKb.actualCommand !== command) { return false; } if (keybinding) { diff --git a/src/vs/platform/keybinding/test/common/keybindingService.test.ts b/src/vs/platform/keybinding/test/common/keybindingService.test.ts index e00279c2f54e0d59cf4171849a4756cf0993ff28..cef8b12bd9e8529dd05b0cd9a13349b7674e9af7 100644 --- a/src/vs/platform/keybinding/test/common/keybindingService.test.ts +++ b/src/vs/platform/keybinding/test/common/keybindingService.test.ts @@ -271,6 +271,33 @@ suite('Keybinding Service', () => { ]); }); + test('issue #612#issuecomment-222109084 cannot remove keybindings for commands with ^', function() { + let defaults:IKeybindingItem[] = [{ + command: '^yes1', + when: KbExpr.equals('1', 'a'), + keybinding: KeyCode.KEY_A, + weight1: 0, + weight2: 0 + }, { + command: 'yes2', + when: KbExpr.equals('2', 'b'), + keybinding: KeyCode.KEY_B, + weight1: 0, + weight2: 0 + }]; + let overrides:IKeybindingItem[] = [{ + command: '-yes1', + when: null, + keybinding: KeyCode.KEY_A, + weight1: 0, + weight2: 0 + }]; + let actual = KeybindingResolver.combine(defaults, overrides); + assert.deepEqual(actual, [ + new NormalizedKeybindingItem(KeyCode.KEY_B, 'yes2', KbExpr.equals('2', 'b'), true) + ]); + }); + test('normalizeRule', function() { let key1IsTrue = KbExpr.equals('key1', true); let key1IsNotFalse = KbExpr.notEquals('key1', false);