( keybindings: ResolvedKeybindingsConfig, command: KeybindingCommand, )
| 35 | } |
| 36 | |
| 37 | export function keybindingValueForCommand( |
| 38 | keybindings: ResolvedKeybindingsConfig, |
| 39 | command: KeybindingCommand, |
| 40 | ): string | null { |
| 41 | for (let index = keybindings.length - 1; index >= 0; index -= 1) { |
| 42 | const binding = keybindings[index]; |
| 43 | if (!binding || binding.command !== command) continue; |
| 44 | |
| 45 | const parts: string[] = []; |
| 46 | if (binding.shortcut.modKey) parts.push("mod"); |
| 47 | if (binding.shortcut.ctrlKey) parts.push("ctrl"); |
| 48 | if (binding.shortcut.metaKey) parts.push("meta"); |
| 49 | if (binding.shortcut.altKey) parts.push("alt"); |
| 50 | if (binding.shortcut.shiftKey) parts.push("shift"); |
| 51 | const keyToken = |
| 52 | binding.shortcut.key === " " |
| 53 | ? "space" |
| 54 | : binding.shortcut.key === "escape" |
| 55 | ? "esc" |
| 56 | : binding.shortcut.key; |
| 57 | parts.push(keyToken); |
| 58 | return parts.join("+"); |
| 59 | } |
| 60 | return null; |
| 61 | } |
no outgoing calls
no test coverage detected