* Check if a chord prefix matches the beginning of a binding's chord.
( prefix: ParsedKeystroke[], binding: ParsedBinding, )
| 121 | * Check if a chord prefix matches the beginning of a binding's chord. |
| 122 | */ |
| 123 | function chordPrefixMatches( |
| 124 | prefix: ParsedKeystroke[], |
| 125 | binding: ParsedBinding, |
| 126 | ): boolean { |
| 127 | if (prefix.length >= binding.chord.length) return false |
| 128 | for (let i = 0; i < prefix.length; i++) { |
| 129 | const prefixKey = prefix[i] |
| 130 | const bindingKey = binding.chord[i] |
| 131 | if (!prefixKey || !bindingKey) return false |
| 132 | if (!keystrokesEqual(prefixKey, bindingKey)) return false |
| 133 | } |
| 134 | return true |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * Check if a full chord matches a binding's chord. |
no test coverage detected