358
}
359
}
361
>
// check there's a keybinding with a matching when clause
362
>
const result = this._findCommand(context, lookupMap);
363
>
if (!result) {
364
this._log(`\\ From ${lookupMap.length} keybinding entries, no when clauses matched the context.`);
365
return NoMatchingKb;
366
}
368
>
// check we got all chords necessary to be sure a particular keybinding needs to be invoked
369
>
if (pressedChords.length < result.chords.length) {
370
// The chord sequence is not complete
371
this._log(`\\ From ${lookupMap.length} keybinding entries, awaiting ${result.chords.length - pressedChords.length} more chord(s), when: ${printWhenExplanation(result.when)}, source: ${printSourceExplanation(result)}.`);
372
return MoreChordsNeeded;
373
}
375
>
this._log(`\\ From ${lookupMap.length} keybinding entries, matched ${result.command}, when: ${printWhenExplanation(result.when)}, source: ${printSourceExplanation(result)}.`);
376
>
377
>
return KbFound(result.command, result.commandArgs, result.bubble);
378
>
}
379
380
private _findCommand(context: IContext, matches: ResolvedKeybindingItem[]): ResolvedKeybindingItem | null {
382
>
const k = matches[i];
383
>
384
>
if (!KeybindingResolver._contextMatchesRules(context, k.when)) {
385
continue;
386
}
388
>
return k;
389
>
}
390
391
return null;
393
394
private static _contextMatchesRules(context: IContext, rules: ContextKeyExpression | null | undefined): boolean {
396
return true;
397
}
398
return rules.evaluate(context);
400
}
401
402
>
function printWhenExplanation(when: ContextKeyExpression | undefined): string {
keybindingResolver.ts
403
>
if (!when) {
404
return `no when condition`;
405
}