|
1 | | -import type { DevToolsClientCommand, DevToolsCommandEntry, DevToolsCommandKeybinding, DevToolsServerCommandEntry } from '@vitejs/devtools-kit' |
| 1 | +import type { DevToolsClientCommand, DevToolsCommandEntry, DevToolsCommandKeybinding, DevToolsServerCommandEntry, WhenContext } from '@vitejs/devtools-kit' |
2 | 2 | import type { CommandsContext, DevToolsRpcClient } from '@vitejs/devtools-kit/client' |
3 | 3 | import type { ShallowRef } from 'vue' |
4 | | -import type { WhenContext } from './keybindings' |
| 4 | +import { evaluateWhen } from '@vitejs/devtools-kit/utils/when' |
5 | 5 | import { computed, markRaw, reactive, ref } from 'vue' |
6 | 6 | import { sharedStateToRef } from './docks' |
7 | | -import { collectAllKeybindings, evaluateWhen, normalizeKeyEvent } from './keybindings' |
| 7 | +import { collectAllKeybindings, normalizeKeyEvent } from './keybindings' |
8 | 8 |
|
9 | 9 | export { formatKeybinding, isMac, normalizeKeyEvent } from './keybindings' |
10 | 10 |
|
@@ -162,12 +162,10 @@ function setupShortcutListener( |
162 | 162 | for (const { id, keybinding } of allBindings) { |
163 | 163 | if (keybinding.key !== pressed) |
164 | 164 | continue |
165 | | - // Check keybinding-level when clause |
166 | | - if (keybinding.when && !evaluateWhen(keybinding.when, whenCtx)) |
167 | | - continue |
168 | 165 | // Check command-level when clause |
169 | | - const cmd = commands.value.find(c => c.id === id) |
170 | | - ?? commands.value.flatMap(c => c.children ?? []).find(c => c.id === id) |
| 166 | + const cmd: DevToolsCommandEntry | undefined |
| 167 | + = commands.value.find(c => c.id === id) |
| 168 | + ?? commands.value.flatMap(c => c.children as DevToolsCommandEntry[] ?? []).find(c => c.id === id) |
171 | 169 | if (cmd?.when && !evaluateWhen(cmd.when, whenCtx)) |
172 | 170 | continue |
173 | 171 |
|
|
0 commit comments