MCPcopy Create free account
hub / github.com/codeaashu/claude-code / resolveKey

Function resolveKey

src/keybindings/resolver.ts:32–61  ·  view source on GitHub ↗
(
  input: string,
  key: Key,
  activeContexts: KeybindingContextName[],
  bindings: ParsedBinding[],
)

Source from the content-addressed store, hash-verified

30 * @returns The resolution result
31 */
32export 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").

Callers

nothing calls this directly

Calls 2

matchesBindingFunction · 0.85
hasMethod · 0.45

Tested by

no test coverage detected