25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
feat(editor): select the current statement with a shortcut and context menu
高桥凉介8a8770066c84
diff --git a/apps/desktop/src/components/editor/QueryEditor.vue b/apps/desktop/src/components/editor/QueryEditor.vueindex 852d12b494..4101a72328 100644--- a/apps/desktop/src/components/editor/QueryEditor.vue+++ b/apps/desktop/src/components/editor/QueryEditor.vue@@ -1195,6 +1195,28 @@ function selectSqlLineFromGutter(currentView: EditorViewType, line: { from: numbreturn true;}+/**+ * 选中光标所在的当前可执行语句(与「执行当前语句」共用同一套范围计算,+ * 边界行为保持一致);属于纯选区操作,不改文档,因此只读编辑器同样可用。+ */+function selectCurrentStatementFromView(currentView: EditorViewType): boolean {+ const range = executableStatementRangeAtPosition(currentView, currentView.state.selection.main.head);+ if (!range || range.from === range.to) return false;+ currentView.dispatch({+ selection: { anchor: range.from, head: range.to },+ scrollIntoView: true,+ userEvent: "select.keyboard",+ });+ currentView.focus();+ return true;+}++function selectCurrentStatementFromContextMenu(): void {+ const currentView = view.value;+ if (!currentView) return;+ selectCurrentStatementFromView(currentView);+}+const contextMenuActions: QueryEditorContextMenuActions = {executeFromContextMenu,executeInNewResultTabFromContextMenu,@@ -1217,6 +1239,7 @@ const contextMenuActions: QueryEditorContextMenuActions = {selectAllSelectionOccurrencesFromContextMenu,openFindReplaceFromContextMenu,deleteEmptyLines,+ selectCurrentStatementFromContextMenu,selectAllSqlFromContextMenu,emitContextObjectAction,openCodeSnapshot,@@ -1389,6 +1412,7 @@ function runKeymapExtension(codeMirrorKeymap: (typeof import("@codemirror/view")...binding(shortcuts.undo, (view) => codeMirrorRuntime.codeMirrorUndo?.(view) ?? false),...binding(shortcuts.redo, (view) => codeMirrorRuntime.codeMirrorRedo?.(view) ?? false),...binding(shortcuts.selectAll, (view) => codeMirrorRuntime.codeMirrorSelectAll?.(view) ?? false),+ ...binding(shortcuts.selectCurrentStatement, selectCurrentStatementFromView),...binding(shortcuts.extendSelection, extendQueryEditorSelectionForView),...binding(shortcuts.addNextSelectionOccurrence, addNextQueryEditorSelectionOccurrence),...binding(shortcuts.selectAllSelectionOccurrences, selectAllQueryEditorSelectionOccurrences),diff --git a/apps/desktop/src/components/editor/QueryEditorContextMenu.vue b/apps/desktop/src/components/editor/QueryEditorContextMenu.vueindex 5f19116996..a5fc325d12 100644--- a/apps/desktop/src/components/editor/QueryEditorContextMenu.vue+++ b/apps/desktop/src/components/editor/QueryEditorContextMenu.vue@@ -79,6 +79,7 @@ export interface QueryEditorContextMenuActions {selectAllSelectionOccurrencesFromContextMenu: () => void;openFindReplaceFromContextMenu: () => void;deleteEmptyLines: () => void;+ selectCurrentStatementFromContextMenu: () => void;selectAllSqlFromContextMenu: () => void;emitContextObjectAction: (action: QueryContextObjectAction) => void;openCodeSnapshot: () => void;@@ -348,6 +349,12 @@ const contextMenuItems = computed<ContextMenuItem[]>(() => {icon: TextSelect,shortcut: shortcuts.selectAllSelectionOccurrences,},+ {+ label: t("editor.contextMenu.selectCurrentStatement"),+ action: actions.selectCurrentStatementFromContextMenu,+ icon: TextSelect,+ shortcut: shortcuts.selectCurrentStatement,+ },{ label: "", separator: true },{label: t("editor.contextMenu.findReplace"),diff --git a/apps/desktop/src/components/editor/__tests__/QueryEditorSelectCurrentStatement.integration.spec.ts b/apps/desktop/src/components/editor/__tests__/QueryEditorSelectCurrentStatement.integration.spec.tsnew file mode 100644index 0000000000..acef7eeec2--- /dev/null+++ b/apps/desktop/src/components/editor/__tests__/QueryEditorSelectCurrentStatement.integration.spec.ts@@ -0,0 +1,123 @@+// @vitest-environment happy-dom++import { createApp, h, nextTick, reactive, shallowRef } from "vue";+import { createPinia, setActivePinia } from "pinia";+import { createI18n } from "vue-i18n";+import { EditorView } from "@codemirror/view";+import { afterEach, describe, expect, it, vi } from "vitest";+import QueryEditor from "../QueryEditor.vue";+import { useSettingsStore } from "@/stores/settingsStore";+import { useConnectionStore } from "@/stores/connectionStore";+import type { QueryEditorProps } from "../queryEditorTypes";++vi.mock("@/lib/common/clipboard", () => ({+ copyToClipboard: vi.fn().mockResolvedValue(undefined),+ readTextFromClipboard: vi.fn().mockResolvedValue(""),+}));++const cleanups: Array<() => void> = [];++afterEach(() => {+ for (const cleanup of cleanups.splice(0).reverse()) cleanup();+ vi.restoreAllMocks();+});++async function mountEditor(modelValue: string, overrides: Partial<QueryEditorProps> = {}) {+ const pinia = createPinia();+ setActivePinia(pinia);+ const settingsStore = useSettingsStore();+ useConnectionStore();+ settingsStore.editorSettings.showExecutionTargetPicker = false;+ settingsStore.editorSettings.executeMode = "current";+ settingsStore.editorSettings.executeAllOnBlankLine = false;+ // 快捷键用显式修饰键(而不是 Mod)书写,让用例在所有平台上确定性地触发,+ // 与 QueryEditorSearchKeymap.spec.ts 的做法一致。+ settingsStore.editorSettings.shortcuts.selectCurrentStatement = "Ctrl+Shift+E";+ const props = reactive<QueryEditorProps>({ modelValue, tabId: "select-current-statement", databaseType: "mysql", dialect: "mysql", autoFocus: false, ...overrides });+ const editor = shallowRef<InstanceType<typeof QueryEditor>>();+ const host = document.createElement("div");+ document.body.append(host);+ const app = createApp({+ render: () =>+ h(QueryEditor, {+ ...props,+ ref: editor,+ "onUpdate:modelValue": (value: string) => {+ props.modelValue = value;+ },+ }),+ });+ app.use(pinia);+ app.use(createI18n({ legacy: false, locale: "en", messages: { en: {} }, missingWarn: false, fallbackWarn: false }));+ app.mount(host);+ cleanups.push(() => {+ app.unmount();+ host.remove();+ });+ await vi.waitFor(() => expect(host.querySelector(".cm-editor")).not.toBeNull(), { timeout: 5000 });+ const view = EditorView.findFromDOM(host.querySelector(".cm-editor") as HTMLElement)!;+ return { view, props, settingsStore };+}++/** 派发选中当前语句的快捷键(Ctrl+Shift+E 在所有平台归一化结果一致) */+function pressSelectCurrentStatement(view: EditorView): KeyboardEvent {+ const event = new KeyboardEvent("keydown", { key: "E", keyCode: 69, code: "KeyE", ctrlKey: true, shiftKey: true, bubbles: true, cancelable: true });+ Object.defineProperty(event, "keyCode", { get: () => 69 });+ view.contentDOM.dispatchEvent(event);+ return event;+}++function selectedText(view: EditorView): string {+ const { from, to } = view.state.selection.main;+ return view.state.sliceDoc(from, to);+}++function placeCursor(view: EditorView, offset: number) {+ view.dispatch({ selection: { anchor: offset } });+}++describe("QueryEditor select current statement", () => {+ it("selects the statement under the cursor without the trailing semicolon", async () => {+ const sql = "SELECT 1;\nSELECT 2 FROM t;\nSELECT 3;";+ const { view } = await mountEditor(sql);+ placeCursor(view, sql.indexOf("SELECT 2") + 5);++ pressSelectCurrentStatement(view);+ await nextTick();++ expect(selectedText(view)).toBe("SELECT 2 FROM t");+ });++ it("ignores semicolons inside string literals", async () => {+ const sql = "SELECT ';' FROM t;\nSELECT 2;";+ const { view } = await mountEditor(sql);+ placeCursor(view, sql.indexOf("SELECT 2") + 3);++ pressSelectCurrentStatement(view);+ await nextTick();++ expect(selectedText(view)).toBe("SELECT 2");+ });++ it("keeps selection-only behavior available in read-only editors", async () => {+ const sql = "SELECT 1;\nSELECT 2;";+ const { view } = await mountEditor(sql, { readOnly: true });+ placeCursor(view, sql.indexOf("SELECT 2") + 2);++ pressSelectCurrentStatement(view);+ await nextTick();++ expect(selectedText(view)).toBe("SELECT 2");+ });++ it("leaves the selection untouched when there is no executable statement", async () => {+ const { view } = await mountEditor("-- only a comment");+ placeCursor(view, 3);++ pressSelectCurrentStatement(view);+ await nextTick();++ expect(selectedText(view)).toBe("");+ expect(view.state.selection.main.empty).toBe(true);+ });+});diff --git a/apps/desktop/src/i18n/__tests__/selectCurrentStatementLocaleParity.spec.ts b/apps/desktop/src/i18n/__tests__/selectCurrentStatementLocaleParity.spec.tsnew file mode 100644index 0000000000..eb2a3d94df--- /dev/null+++ b/apps/desktop/src/i18n/__tests__/selectCurrentStatementLocaleParity.spec.ts@@ -0,0 +1,26 @@+import { readFileSync } from "node:fs";+import { describe, expect, it } from "vitest";++// 「选中当前语句」的快捷键设置项与右键菜单文案,必须由每种语言的源文件自己声明:+// 导入的 locale 会经 `withEnglishFallback` 深合并英文,缺 key 时仍能解析(但会显示英文),+// 因此这里直接断言源文件(合并前),避免静默回落。++function localeSource(name: string): string {+ return readFileSync(new URL(`../locales/${name}.ts`, import.meta.url), "utf8");+}++// 与 ../index.ts 的 supportedLocales 保持一致(12 种语言)+const LOCALES = ["en", "zh-CN", "zh-TW", "ja", "ko", "es", "it", "pt-BR", "ru", "az", "tr", "id"] as const;++function declaredString(source: string, key: string): string | undefined {+ return source.match(new RegExp(String.raw`^\s*${key}:\s*"((?:[^"\\]|\\.)*)",\s*$`, "m"))?.[1];+}++describe("select current statement locale parity", () => {+ it.each(LOCALES)("%s declares the shortcut and context-menu labels", (name) => {+ const source = localeSource(name);++ expect(declaredString(source, "shortcutSelectCurrentStatement"), `${name}: settings.shortcutSelectCurrentStatement is missing`).toBeTruthy();+ expect(declaredString(source, "selectCurrentStatement"), `${name}: editor.contextMenu.selectCurrentStatement is missing`).toBeTruthy();+ });+});diff --git a/apps/desktop/src/i18n/locales/az.ts b/apps/desktop/src/i18n/locales/az.tsindex 6cda225005..fe43b178a3 100644--- a/apps/desktop/src/i18n/locales/az.ts+++ b/apps/desktop/src/i18n/locales/az.ts@@ -1534,6 +1534,7 @@ export default withEnglishFallback({delimitedList: "Ayırıcı ilə ayrılmış siyahıya çevir",addNextSelectionOccurrence: "Növbəti uyğunluğu əlavə et",selectAllSelectionOccurrences: "Bütün uyğunluqları seç",+ selectCurrentStatement: "Cari ifadəni seç",expandSelectStar: "* işarəsini sütunlarla əvəz et",expandSelectStarUnavailable: "Bu cədvəlin sütunlarını yükləmək mümkün deyil",findReplace: "Tap/əvəz et",@@ -7824,6 +7825,7 @@ export default withEnglishFallback({shortcutUndo: "Geri al",shortcutRedo: "Təkrar et",shortcutSelectAll: "Hamısını seç",+ shortcutSelectCurrentStatement: "Cari ifadəni seç",shortcutAddNextSelectionOccurrence: "Növbəti uyğunluğu əlavə et",shortcutSelectAllSelectionOccurrences: "Bütün uyğunluqları seç",shortcutExtendSelection: "Seçimi genişləndir",diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.tsindex cc55b6a4dd..9fa3630a25 100644--- a/apps/desktop/src/i18n/locales/en.ts+++ b/apps/desktop/src/i18n/locales/en.ts@@ -1858,6 +1858,7 @@ export default {delimitedList: "Convert to delimited list",addNextSelectionOccurrence: "Add next occurrence",selectAllSelectionOccurrences: "Select all occurrences",+ selectCurrentStatement: "Select current statement",expandSelectStar: "Expand * to columns",expandSelectStarUnavailable: "Unable to load columns for this table",findReplace: "Find/Replace",@@ -8849,6 +8850,7 @@ export default {shortcutUndo: "Undo",shortcutRedo: "Redo",shortcutSelectAll: "Select all",+ shortcutSelectCurrentStatement: "Select current statement",shortcutAddNextSelectionOccurrence: "Add next occurrence",shortcutSelectAllSelectionOccurrences: "Select all occurrences",shortcutSelectLineEnds: "Select line ends",diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.tsindex 787d2aa4f3..fb80976acb 100644--- a/apps/desktop/src/i18n/locales/es.ts+++ b/apps/desktop/src/i18n/locales/es.ts@@ -1843,6 +1843,7 @@ export default withEnglishFallback({delimitedList: "Convertir a lista delimitada",addNextSelectionOccurrence: "Añadir siguiente coincidencia",selectAllSelectionOccurrences: "Seleccionar todas las coincidencias",+ selectCurrentStatement: "Seleccionar la sentencia actual",expandSelectStar: "Expandir * a columnas",expandSelectStarUnavailable: "No se pudieron cargar las columnas de esta tabla",findReplace: "Buscar/Reemplazar",@@ -8099,6 +8100,7 @@ export default withEnglishFallback({shortcutUndo: "Deshacer",shortcutRedo: "Rehacer",shortcutSelectAll: "Seleccionar todo",+ shortcutSelectCurrentStatement: "Seleccionar la sentencia actual",shortcutAddNextSelectionOccurrence: "Añadir siguiente coincidencia",shortcutSelectAllSelectionOccurrences: "Seleccionar todas las coincidencias",shortcutExtendSelection: "Ampliar selección",diff --git a/apps/desktop/src/i18n/locales/id.ts b/apps/desktop/src/i18n/locales/id.tsindex d4845975c4..39ad4faf91 100644--- a/apps/desktop/src/i18n/locales/id.ts+++ b/apps/desktop/src/i18n/locales/id.ts@@ -1774,6 +1774,7 @@ export default withEnglishFallback({delimitedList: "Konversi ke daftar berpemisah",addNextSelectionOccurrence: "Tambah kemunculan berikutnya",selectAllSelectionOccurrences: "Pilih semua kemunculan",+ selectCurrentStatement: "Pilih pernyataan saat ini",expandSelectStar: "Perluas * menjadi kolom",expandSelectStarUnavailable: "Tidak dapat memuat kolom untuk tabel ini",findReplace: "Cari/Ganti",@@ -8623,6 +8624,7 @@ export default withEnglishFallback({shortcutUndo: "Urungkan",shortcutRedo: "Ulangi",shortcutSelectAll: "Pilih semua",+ shortcutSelectCurrentStatement: "Pilih pernyataan saat ini",shortcutAddNextSelectionOccurrence: "Tambah kemunculan berikutnya",shortcutSelectAllSelectionOccurrences: "Pilih semua kemunculan",shortcutExtendSelection: "Perluas seleksi",diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.tsindex 542518ea9b..f115988759 100644--- a/apps/desktop/src/i18n/locales/it.ts+++ b/apps/desktop/src/i18n/locales/it.ts@@ -1752,6 +1752,7 @@ export default withEnglishFallback({delimitedList: "Converti in lista delimitata",addNextSelectionOccurrence: "Aggiungi occorrenza successiva",selectAllSelectionOccurrences: "Seleziona tutte le occorrenze",+ selectCurrentStatement: "Seleziona l'istruzione corrente",expandSelectStar: "Espandi * in colonne",expandSelectStarUnavailable: "Impossibile caricare le colonne di questa tabella",findReplace: "Trova/Sostituisci",@@ -7861,6 +7862,7 @@ export default withEnglishFallback({shortcutUndo: "Annulla",shortcutRedo: "Ripeti",shortcutSelectAll: "Seleziona tutto",+ shortcutSelectCurrentStatement: "Seleziona l'istruzione corrente",shortcutAddNextSelectionOccurrence: "Aggiungi occorrenza successiva",shortcutSelectAllSelectionOccurrences: "Seleziona tutte le occorrenze",shortcutExtendSelection: "Estendi selezione",diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.tsindex c42337410c..78678e41d8 100644--- a/apps/desktop/src/i18n/locales/ja.ts+++ b/apps/desktop/src/i18n/locales/ja.ts@@ -1772,6 +1772,7 @@ export default withEnglishFallback({delimitedList: "区切り文字付きリストに変換",addNextSelectionOccurrence: "次の出現箇所を選択に追加",selectAllSelectionOccurrences: "すべての出現箇所を選択",+ selectCurrentStatement: "現在のステートメントを選択",expandSelectStar: "* を列に展開",expandSelectStarUnavailable: "このテーブルの列を読み込めません",findReplace: "検索/置換",@@ -7855,6 +7856,7 @@ export default withEnglishFallback({shortcutUndo: "元に戻す",shortcutRedo: "やり直す",shortcutSelectAll: "すべて選択",+ shortcutSelectCurrentStatement: "現在のステートメントを選択",shortcutAddNextSelectionOccurrence: "次の出現箇所を選択に追加",shortcutSelectAllSelectionOccurrences: "すべての出現箇所を選択",shortcutExtendSelection: "選択範囲を拡張",diff --git a/apps/desktop/src/i18n/locales/ko.ts b/apps/desktop/src/i18n/locales/ko.tsindex e3bdea12fb..66b0907cae 100644--- a/apps/desktop/src/i18n/locales/ko.ts+++ b/apps/desktop/src/i18n/locales/ko.ts@@ -1682,6 +1682,7 @@ export default withEnglishFallback({delimitedList: "구분자 목록으로 변환",addNextSelectionOccurrence: "다음 일치 항목 선택 추가",selectAllSelectionOccurrences: "모든 일치 항목 선택",+ selectCurrentStatement: "현재 문 선택",expandSelectStar: "*을(를) 열로 확장",expandSelectStarUnavailable: "이 테이블의 열을 불러올 수 없습니다",findReplace: "찾기/바꾸기",@@ -7710,6 +7711,7 @@ export default withEnglishFallback({shortcutUndo: "실행 취소",shortcutRedo: "다시 실행",shortcutSelectAll: "모두 선택",+ shortcutSelectCurrentStatement: "현재 문 선택",shortcutAddNextSelectionOccurrence: "다음 일치 항목 선택 추가",shortcutSelectAllSelectionOccurrences: "모든 일치 항목 선택",shortcutEditCell: "셀 편집",diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.tsindex f31c3c1ac0..b1e8a1f58e 100644--- a/apps/desktop/src/i18n/locales/pt-BR.ts+++ b/apps/desktop/src/i18n/locales/pt-BR.ts@@ -1753,6 +1753,7 @@ export default withEnglishFallback({delimitedList: "Converter para lista delimitada",addNextSelectionOccurrence: "Adicionar próxima ocorrência",selectAllSelectionOccurrences: "Selecionar todas as ocorrências",+ selectCurrentStatement: "Selecionar a instrução atual",expandSelectStar: "Expandir * em colunas",expandSelectStarUnavailable: "Não foi possível carregar as colunas desta tabela",findReplace: "Localizar/substituir",@@ -7861,6 +7862,7 @@ export default withEnglishFallback({shortcutUndo: "Desfazer",shortcutRedo: "Refazer",shortcutSelectAll: "Selecionar tudo",+ shortcutSelectCurrentStatement: "Selecionar a instrução atual",shortcutAddNextSelectionOccurrence: "Adicionar próxima ocorrência",shortcutSelectAllSelectionOccurrences: "Selecionar todas as ocorrências",shortcutExtendSelection: "Expandir seleção",diff --git a/apps/desktop/src/i18n/locales/ru.ts b/apps/desktop/src/i18n/locales/ru.tsindex 6a27eeb528..4f35e4cc2d 100644--- a/apps/desktop/src/i18n/locales/ru.ts+++ b/apps/desktop/src/i18n/locales/ru.ts@@ -1766,6 +1766,7 @@ export default withEnglishFallback({delimitedList: "Преобразовать в список с разделителями",addNextSelectionOccurrence: "Добавить следующее вхождение",selectAllSelectionOccurrences: "Выбрать все вхождения",+ selectCurrentStatement: "Выделить текущую инструкцию",expandSelectStar: "Раскрыть * в столбцы",expandSelectStarUnavailable: "Не удалось загрузить столбцы этой таблицы",findReplace: "Найти/Заменить",@@ -9150,6 +9151,7 @@ export default withEnglishFallback({shortcutUndo: "Отменить",shortcutRedo: "Повторить",shortcutSelectAll: "Выделить всё",+ shortcutSelectCurrentStatement: "Выделить текущую инструкцию",shortcutAddNextSelectionOccurrence: "Добавить следующее вхождение",shortcutSelectAllSelectionOccurrences: "Выделить все вхождения",shortcutExtendSelection: "Расширить выделение",diff --git a/apps/desktop/src/i18n/locales/tr.ts b/apps/desktop/src/i18n/locales/tr.tsindex 668eed2df2..4d7711458c 100644--- a/apps/desktop/src/i18n/locales/tr.ts+++ b/apps/desktop/src/i18n/locales/tr.ts@@ -1533,6 +1533,7 @@ export default withEnglishFallback({delimitedList: "Ayırıcılı listeye dönüştür",addNextSelectionOccurrence: "Sonraki eşleşmeyi ekle",selectAllSelectionOccurrences: "Tüm eşleşmeleri seç",+ selectCurrentStatement: "Geçerli ifadeyi seç",expandSelectStar: "* ifadesini sütunlara genişlet",expandSelectStarUnavailable: "Bu tablonun sütunları yüklenemedi",findReplace: "Bul/Değiştir",@@ -7725,6 +7726,7 @@ export default withEnglishFallback({shortcutUndo: "Geri al",shortcutRedo: "Yinele",shortcutSelectAll: "Tümünü seç",+ shortcutSelectCurrentStatement: "Geçerli ifadeyi seç",shortcutAddNextSelectionOccurrence: "Sonraki eşleşmeyi ekle",shortcutSelectAllSelectionOccurrences: "Tüm eşleşmeleri seç",shortcutExtendSelection: "Seçimi genişlet",diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.tsindex 503035b4d8..f6bed9f95b 100644--- a/apps/desktop/src/i18n/locales/zh-CN.ts+++ b/apps/desktop/src/i18n/locales/zh-CN.ts@@ -1794,6 +1794,7 @@ export default withEnglishFallback({delimitedList: "转换为带分隔符的列表",addNextSelectionOccurrence: "增加下一个选中词",selectAllSelectionOccurrences: "选中所有选中词",+ selectCurrentStatement: "选中当前语句",expandSelectStar: "将 * 展开为字段",expandSelectStarUnavailable: "无法读取该表的字段信息",findReplace: "查找/替换",@@ -8831,6 +8832,7 @@ export default withEnglishFallback({shortcutUndo: "撤销",shortcutRedo: "重做",shortcutSelectAll: "全选",+ shortcutSelectCurrentStatement: "选中当前语句",shortcutAddNextSelectionOccurrence: "增加下一个选中词",shortcutSelectAllSelectionOccurrences: "选中所有选中词",shortcutSelectLineEnds: "选中行尾",diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.tsindex 731e0855a3..a21e1e01c4 100644--- a/apps/desktop/src/i18n/locales/zh-TW.ts+++ b/apps/desktop/src/i18n/locales/zh-TW.ts@@ -1756,6 +1756,7 @@ export default withEnglishFallback({delimitedList: "轉換為帶分隔符的清單",addNextSelectionOccurrence: "增加下一個選取詞",selectAllSelectionOccurrences: "選取所有選取詞",+ selectCurrentStatement: "選取目前語句",expandSelectStar: "將 * 展開為欄位",expandSelectStarUnavailable: "無法讀取此資料表的欄位資訊",findReplace: "查找/取代",@@ -7180,6 +7181,7 @@ export default withEnglishFallback({shortcutUndo: "復原",shortcutRedo: "重做",shortcutSelectAll: "全選",+ shortcutSelectCurrentStatement: "選取目前語句",shortcutAddNextSelectionOccurrence: "增加下一個選取詞",shortcutSelectAllSelectionOccurrences: "選取所有選取詞",shortcutExtendSelection: "擴展選取範圍",diff --git a/apps/desktop/src/lib/__tests__/editor/shortcutRegistry.spec.ts b/apps/desktop/src/lib/__tests__/editor/shortcutRegistry.spec.tsindex 518e66741c..d4aceea8be 100644--- a/apps/desktop/src/lib/__tests__/editor/shortcutRegistry.spec.ts+++ b/apps/desktop/src/lib/__tests__/editor/shortcutRegistry.spec.ts@@ -193,6 +193,16 @@ describe("shortcutRegistry editor actions", () => {expect(findShortcutConflict("explainSql", "Mod+E", DEFAULT_SHORTCUT_SETTINGS)).toBeNull();});+ it("registers a configurable editor shortcut for selecting the current statement", () => {+ const definition = SHORTCUT_DEFINITIONS.find((item) => item.id === "selectCurrentStatement");++ expect(definition).toMatchObject({ labelKey: "settings.shortcutSelectCurrentStatement", scope: "editor", defaultShortcut: "Mod+Shift+E" });+ expect(shortcutToCodeMirrorKey(DEFAULT_SHORTCUT_SETTINGS.selectCurrentStatement)).toBe("Mod-Shift-e");+ expect(findShortcutConflict("selectCurrentStatement", DEFAULT_SHORTCUT_SETTINGS.selectCurrentStatement, DEFAULT_SHORTCUT_SETTINGS)).toBeNull();+ // 与侧栏「断开连接」同键属于有意的跨作用域复用(仅提示,不影响编辑器内触发)+ expect(findCrossScopeShortcutConflicts(DEFAULT_SHORTCUT_SETTINGS).selectCurrentStatement).toContain("disconnectSidebarConnection");+ });+it("keeps current-view search and editor find contextual on Mod+F", () => {const focusSearch = SHORTCUT_DEFINITIONS.find((item) => item.id === "focusSearch");const find = SHORTCUT_DEFINITIONS.find((item) => item.id === "find");diff --git a/apps/desktop/src/lib/editor/shortcutRegistry.ts b/apps/desktop/src/lib/editor/shortcutRegistry.tsindex 7d795abd2b..da51e48681 100644--- a/apps/desktop/src/lib/editor/shortcutRegistry.ts+++ b/apps/desktop/src/lib/editor/shortcutRegistry.ts@@ -24,6 +24,7 @@ export type ShortcutActionId =| "undo"| "redo"| "selectAll"+ | "selectCurrentStatement"| "extendSelection"| "addNextSelectionOccurrence"| "selectAllSelectionOccurrences"@@ -310,6 +311,12 @@ export const SHORTCUT_DEFINITIONS: ShortcutDefinition[] = [scope: "editor",defaultShortcut: "Mod+A",},+ {+ id: "selectCurrentStatement",+ labelKey: "settings.shortcutSelectCurrentStatement",+ scope: "editor",+ defaultShortcut: "Mod+Shift+E",+ },{id: "extendSelection",labelKey: "settings.shortcutExtendSelection",