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

Function resolveKey

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

Source from the content-addressed store, hash-verified

32 * @returns The resolution result
33 */
34export function resolveKey(
35 input: string,
36 key: Key,
37 activeContexts: KeybindingContextName[],
38 bindings: ParsedBinding[],
39): ResolveResult {
40 // Find matching bindings (last one wins for user overrides)
41 let match: ParsedBinding | undefined
42 const ctxSet = new Set(activeContexts)
43
44 for (const binding of bindings) {
45 // Phase 1: Only single-keystroke bindings
46 if (binding.chord.length !== 1) continue
47 if (!ctxSet.has(binding.context)) continue
48
49 if (matchesBinding(input, key, binding)) {
50 match = binding
51 }
52 }
53
54 if (!match) {
55 return { type: 'none' }
56 }
57
58 if (match.action === null) {
59 return { type: 'unbound' }
60 }
61
62 return { type: 'match', action: match.action }
63}
64
65/**
66 * 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