Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/components/ui/SqlEditorWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useEditorTheme } from "../../hooks/useEditorTheme";
import { loadMonacoTheme } from "../../themes/themeUtils";
import { readText } from "@tauri-apps/plugin-clipboard-manager";
import { useSettings } from "../../hooks/useSettings";
import { useKeybindings } from "../../hooks/useKeybindings";
import { getFontCSS } from "../../utils/settings";

interface SqlEditorWrapperProps {
Expand Down Expand Up @@ -33,6 +34,9 @@ const SqlEditorInternal = ({
onRunRef.current = onRun;
const editorTheme = useEditorTheme();
const { settings } = useSettings();
const { matchesShortcut } = useKeybindings();
const matchesShortcutRef = useRef(matchesShortcut);
matchesShortcutRef.current = matchesShortcut;

// Dispose editor on unmount to prevent "domNode" errors from ResizeObserver
// firing after the DOM container is removed (e.g., cell deletion/movement)
Expand Down Expand Up @@ -141,6 +145,15 @@ const SqlEditorInternal = ({
}
);

// Force the suggestion widget via the user-configurable shortcut
editor.onKeyDown((e) => {
if (matchesShortcutRef.current(e.browserEvent, "trigger_suggestions")) {
e.preventDefault();
e.stopPropagation();
editor.trigger("keyboard", "editor.action.triggerSuggest", {});
}
});

if (onMount) onMount(editor, monaco);
};

Expand Down
20 changes: 20 additions & 0 deletions src/config/shortcuts.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@
"i18nKey": "settings.shortcuts.saveGridChanges",
"overridable": true
},
{
"id": "refresh_table",
"category": "data_grid",
"defaultMac": "⌘+R",
"defaultWin": "Ctrl+R",
"macMatch": { "metaKey": true, "key": "r" },
"winMatch": { "ctrlKey": true, "key": "r" },
"i18nKey": "settings.shortcuts.refreshTable",
"overridable": true
},
{
"id": "tab_switcher",
"category": "editor",
Expand Down Expand Up @@ -158,5 +168,15 @@
"winMatch": { "ctrlKey": true, "key": "p" },
"i18nKey": "settings.shortcuts.quickNavigator",
"overridable": true
},
{
"id": "trigger_suggestions",
"category": "editor",
"defaultMac": "⌘+I",
"defaultWin": "Ctrl+Space",
"macMatch": { "metaKey": true, "key": "i" },
"winMatch": { "ctrlKey": true, "key": " " },
"i18nKey": "settings.shortcuts.triggerSuggestions",
"overridable": true
}
]
4 changes: 3 additions & 1 deletion src/i18n/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,9 @@
"notebookRunAll": "Alle Zellen ausführen",
"categories_notebook": "Notebook",
"pasteImportClipboard": "Aus Zwischenablage importieren",
"quickNavigator": "Schnellnavigation"
"quickNavigator": "Schnellnavigation",
"triggerSuggestions": "Vorschläge anzeigen",
"refreshTable": "Tabelle aktualisieren"
},
"aiActivity": "KI-Aktivität"
},
Expand Down
4 changes: 3 additions & 1 deletion src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,9 @@
"notebookRunAll": "Run All Cells",
"categories_notebook": "Notebook",
"pasteImportClipboard": "Import from Clipboard",
"quickNavigator": "Quick Navigator"
"quickNavigator": "Quick Navigator",
"triggerSuggestions": "Trigger suggestions",
"refreshTable": "Refresh table"
},
"aiActivity": "AI Activity"
},
Expand Down
4 changes: 3 additions & 1 deletion src/i18n/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,9 @@
"notebookRunAll": "Ejecutar Todas las Celdas",
"categories_notebook": "Notebook",
"pasteImportClipboard": "Importar desde Portapapeles",
"quickNavigator": "Navegador rápido"
"quickNavigator": "Navegador rápido",
"triggerSuggestions": "Mostrar sugerencias",
"refreshTable": "Actualizar tabla"
},
"aiActivity": "Actividad IA"
},
Expand Down
4 changes: 3 additions & 1 deletion src/i18n/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,9 @@
"notebookRunAll": "Exécuter toutes les cellules",
"categories_notebook": "Notebook",
"pasteImportClipboard": "Importer depuis le Presse-papiers",
"quickNavigator": "Navigateur rapide"
"quickNavigator": "Navigateur rapide",
"triggerSuggestions": "Afficher les suggestions",
"refreshTable": "Actualiser la table"
},
"aiActivity": "Activité IA"
},
Expand Down
4 changes: 3 additions & 1 deletion src/i18n/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,9 @@
"notebookRunAll": "Esegui Tutte le Celle",
"categories_notebook": "Notebook",
"pasteImportClipboard": "Importa dagli Appunti",
"quickNavigator": "Navigatore rapido"
"quickNavigator": "Navigatore rapido",
"triggerSuggestions": "Mostra suggerimenti",
"refreshTable": "Aggiorna tabella"
},
"aiActivity": "Attività AI"
},
Expand Down
4 changes: 3 additions & 1 deletion src/i18n/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,9 @@
"notebookRunAll": "すべてのセルを実行",
"categories_notebook": "ノートブック",
"pasteImportClipboard": "クリップボードからインポート",
"quickNavigator": "クイックナビゲーター"
"quickNavigator": "クイックナビゲーター",
"triggerSuggestions": "候補を表示",
"refreshTable": "テーブルを更新"
},
"aiActivity": "AI アクティビティ"
},
Expand Down
4 changes: 3 additions & 1 deletion src/i18n/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,9 @@
"notebookRunAll": "Выполнить все ячейки",
"categories_notebook": "Ноутбук",
"pasteImportClipboard": "Импортировать из буфера обмена",
"quickNavigator": "Быстрый навигатор"
"quickNavigator": "Быстрый навигатор",
"triggerSuggestions": "Показать подсказки",
"refreshTable": "Обновить таблицу"
},
"aiActivity": "Активность AI"
},
Expand Down
4 changes: 3 additions & 1 deletion src/i18n/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,9 @@
"pressKeys": "按下组合键...",
"notebookRunAll": "运行所有单元格",
"categories_notebook": "笔记本",
"quickNavigator": "快速导航"
"quickNavigator": "快速导航",
"triggerSuggestions": "触发建议",
"refreshTable": "刷新表格"
},
"aiActivity": "AI 活动"
},
Expand Down
11 changes: 11 additions & 0 deletions src/pages/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,17 @@ export const Editor = () => {
}
return;
}

if (matchesShortcut(e, "refresh_table")) {
const tab = tabsRef.current.find(
(t) => t.id === activeTabIdRef.current,
);
if (tab?.activeTable) {
e.preventDefault();
runQuery(tab.query, tab.page);
}
return;
}
};
window.addEventListener("keydown", handleKeyDown);
return () => window.removeEventListener("keydown", handleKeyDown);
Expand Down
7 changes: 7 additions & 0 deletions tests/components/ui/SqlEditorWrapper.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ vi.mock('../../../src/hooks/useTheme', () => ({
})),
}));

// Mock useKeybindings hook
vi.mock('../../../src/hooks/useKeybindings', () => ({
useKeybindings: vi.fn(() => ({
matchesShortcut: vi.fn(() => false),
})),
}));

// Mock themeUtils
vi.mock('../../../src/themes/themeUtils', () => ({
loadMonacoTheme: vi.fn(),
Expand Down