( input: string, key: Key, activeContexts: KeybindingContextName[], bindings: ParsedBinding[], )
| 30 | * @returns The resolution result |
| 31 | */ |
| 32 | export function resolveKey( |
| 33 | input: string, |
| 34 | key: Key, |
| 35 | activeContexts: KeybindingContextName[], |
| 36 | bindings: ParsedBinding[], |
| 37 | ): ResolveResult { |
| 38 | // Find matching bindings (last one wins for user overrides) |
| 39 | let match: ParsedBinding | undefined |
| 40 | const ctxSet = new Set(activeContexts) |
| 41 | |
| 42 | for (const binding of bindings) { |
| 43 | // Phase 1: Only single-keystroke bindings |
| 44 | if (binding.chord.length !== 1) continue |
| 45 | if (!ctxSet.has(binding.context)) continue |
| 46 | |
| 47 | if (matchesBinding(input, key, binding)) { |
| 48 | match = binding |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | if (!match) { |
| 53 | return { type: 'none' } |
| 54 | } |
| 55 | |
| 56 | if (match.action === null) { |
| 57 | return { type: 'unbound' } |
| 58 | } |
| 59 | |
| 60 | return { type: 'match', action: match.action } |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Get display text for an action from bindings (e.g., "ctrl+t" for "app:toggleTodos"). |
nothing calls this directly
no test coverage detected