( id: KeymapId, input: string, )
| 1300 | } |
| 1301 | |
| 1302 | export 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 |
no test coverage detected