🐛 fix(query-editor): 限制 macOS 搜索仅响应 Cmd+F

- 拦截 Monaco 内置 Cmd+E find-with-selection 行为
- 保留默认 Cmd+E 当前语句选择逻辑,禁用或改键时不触发搜索
- 增加 SQL 编辑器快捷键回归测试并加固 Monaco 测试包装
This commit is contained in:
Syngnat
2026-07-08 20:30:31 +08:00
parent dca1e8a251
commit f74ad02b9d
3 changed files with 136 additions and 12 deletions

View File

@@ -4481,6 +4481,39 @@ describe('QueryEditor external SQL save', () => {
).not.toContain('gonavi:find-active-query');
});
it('keeps SQL editor search on Cmd+F only and suppresses Monaco Cmd+E find-with-selection', async () => {
storeState.shortcutOptions.selectCurrentStatement.mac = { enabled: false, combo: '' };
storeState.shortcutOptions.selectCurrentStatement.windows = { enabled: false, combo: '' };
await act(async () => {
create(<QueryEditor tab={createTab({
query: 'SELECT 1;\nSELECT 2 AS two;\nSELECT 3;',
readOnly: true,
})} />);
});
(window.dispatchEvent as any).mockClear();
(document.execCommand as any).mockClear();
expect(findEditorAction('gonavi.findInEditor')).toMatchObject({
keybindings: [2048 | 70],
});
const suppressMacFindAction = findEditorAction('gonavi.suppressMacFindWithSelection');
expect(suppressMacFindAction).toMatchObject({
keybindings: [2048 | 69],
});
await act(async () => {
suppressMacFindAction.run();
await Promise.resolve();
});
expect(
(window.dispatchEvent as any).mock.calls.map((call: any[]) => call[0]?.type),
).not.toContain('gonavi:find-active-query');
expect(document.execCommand).not.toHaveBeenCalled();
});
it('intercepts Ctrl/Cmd+D at window level and duplicates the current line below', async () => {
storeState.shortcutOptions.duplicateCurrentLine.mac = { enabled: true, combo: 'Meta+D' };
storeState.shortcutOptions.duplicateCurrentLine.windows = { enabled: true, combo: 'Ctrl+D' };