提交 2833eb9d 编写于 作者: A Alex Dima

Fixes #612: Handle ^ commands when removing commands in keybindings.json

上级 bdb06710
......@@ -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) {
......
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册