未验证 提交 87d09c2e 编写于 作者: A Alex Dima

Fixes #126306: Use the global context key service when computing primary keybinding for a command

上级 f1330007
......@@ -111,7 +111,7 @@ export abstract class AbstractKeybindingService extends Disposable implements IK
}
public lookupKeybinding(commandId: string, context?: IContextKeyService): ResolvedKeybinding | undefined {
const result = this._getResolver().lookupPrimaryKeybinding(commandId, context);
const result = this._getResolver().lookupPrimaryKeybinding(commandId, context || this._contextKeyService);
if (!result) {
return undefined;
}
......
......@@ -247,15 +247,23 @@ export class KeybindingResolver {
return result;
}
public lookupPrimaryKeybinding(commandId: string, context?: IContextKeyService): ResolvedKeybindingItem | null {
let items = this._lookupMap.get(commandId);
public lookupPrimaryKeybinding(commandId: string, context: IContextKeyService): ResolvedKeybindingItem | null {
const items = this._lookupMap.get(commandId);
if (typeof items === 'undefined' || items.length === 0) {
return null;
}
if (items.length === 1) {
return items[0];
}
for (let i = items.length - 1; i >= 0; i--) {
const item = items[i];
if (context.contextMatchesRules(item.when)) {
return item;
}
}
const itemMatchingContext = context &&
Array.from(items).reverse().find(item => context.contextMatchesRules(item.when));
return itemMatchingContext ?? items[items.length - 1];
return items[items.length - 1];
}
public resolve(context: IContext, currentChord: string | null, keypress: string): IResolveResult | null {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册