* Filter out reserved shortcuts that cannot be rebound. * These would cause /doctor to warn, so we exclude them from the template.
(blocks: KeybindingBlock[])
| 16 | * These would cause /doctor to warn, so we exclude them from the template. |
| 17 | */ |
| 18 | function filterReservedShortcuts(blocks: KeybindingBlock[]): KeybindingBlock[] { |
| 19 | const reservedKeys = new Set( |
| 20 | NON_REBINDABLE.map(r => normalizeKeyForComparison(r.key)), |
| 21 | ) |
| 22 | |
| 23 | return blocks |
| 24 | .map(block => { |
| 25 | const filteredBindings: Record<string, string | null> = {} |
| 26 | for (const [key, action] of Object.entries(block.bindings)) { |
| 27 | if (!reservedKeys.has(normalizeKeyForComparison(key))) { |
| 28 | filteredBindings[key] = action |
| 29 | } |
| 30 | } |
| 31 | return { context: block.context, bindings: filteredBindings } |
| 32 | }) |
| 33 | .filter(block => Object.keys(block.bindings).length > 0) |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Generate a template keybindings.json file content. |
no test coverage detected