MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / normalizeKeymapBinding

Function normalizeKeymapBinding

packages/app-core/src/lib/keymaps.ts:1302–1323  ·  view source on GitHub ↗
(
  id: KeymapId,
  input: string,
)

Source from the content-addressed store, hash-verified

1300}
1301
1302export function normalizeKeymapBinding(
1303 id: KeymapId,
1304 input: string,
1305): string | null {
1306 const definition = getKeymapDefinition(id);
1307 const normalized =
1308 definition.kind === "shortcut"
1309 ? normalizeShortcutBinding(input)
1310 : normalizeSequenceBinding(input);
1311 if (!normalized) return null;
1312 if (definition.kind === "sequence" && definition.maxTokens) {
1313 const tokenCount = normalized.split(/\s+/).filter(Boolean).length;
1314 if (tokenCount > definition.maxTokens) {
1315 return normalized
1316 .split(/\s+/)
1317 .filter(Boolean)
1318 .slice(0, definition.maxTokens)
1319 .join(" ");
1320 }
1321 }
1322 return normalized;
1323}
1324
1325/**
1326 * Global shortcuts share one always-active namespace, so two actions bound to

Callers 2

findKeymapConflictFunction · 0.85
normalizeKeymapOverridesFunction · 0.85

Calls 3

getKeymapDefinitionFunction · 0.85
normalizeShortcutBindingFunction · 0.85
normalizeSequenceBindingFunction · 0.85

Tested by

no test coverage detected