From 600af875328c19d65aab8800f2dd8b85c75be327 Mon Sep 17 00:00:00 2001 From: Mo-Moore <33098900+Mo-Moore@users.noreply.github.com> Date: Tue, 1 Sep 2026 13:11:58 +0800 Subject: [PATCH] feat(editor): extend insert column hints to select --- .../src/components/editor/QueryEditor.vue | 11 +- .../src/components/layout/EditorToolbar.vue | 25 +++- apps/desktop/src/i18n/locales/en.ts | 4 +- apps/desktop/src/i18n/locales/es.ts | 4 +- apps/desktop/src/i18n/locales/it.ts | 4 +- apps/desktop/src/i18n/locales/ja.ts | 4 +- apps/desktop/src/i18n/locales/ko.ts | 4 +- apps/desktop/src/i18n/locales/pt-BR.ts | 4 +- apps/desktop/src/i18n/locales/zh-CN.ts | 4 +- apps/desktop/src/i18n/locales/zh-TW.ts | 4 +- .../editor/codemirrorInsertValueHints.spec.ts | 20 +++ .../lib/editor/codemirrorInsertValueHints.ts | 77 ++++++++++- apps/desktop/src/lib/sql/insertValueHints.ts | 74 +++++++++- packages/app-tests/insertValueHints.test.ts | 127 +++++++++++++++++- 14 files changed, 341 insertions(+), 25 deletions(-) create mode 100644 apps/desktop/src/lib/__tests__/editor/codemirrorInsertValueHints.spec.ts diff --git a/apps/desktop/src/components/editor/QueryEditor.vue b/apps/desktop/src/components/editor/QueryEditor.vue index 41e34a9280..82a7c5d8a5 100644 --- a/apps/desktop/src/components/editor/QueryEditor.vue +++ b/apps/desktop/src/components/editor/QueryEditor.vue @@ -129,7 +129,7 @@ import { normalizeShortcutSettings, shortcutToCodeMirrorKey } from "@/lib/editor import { trimmedSelectionLayer } from "@/lib/editor/codemirrorTrimmedSelectionLayer"; import { currentStatementFrameLayer } from "@/lib/editor/codemirrorCurrentStatementFrameLayer"; import { selectionMatchOccurrences } from "@/lib/editor/codemirrorSelectionMatches"; -import { createInsertValueHintsExtension, requestInsertValueHintsRefresh } from "@/lib/editor/codemirrorInsertValueHints"; +import { createInsertValueHintsExtension, requestInsertValueHintsRefresh, supportsInsertValueHints } from "@/lib/editor/codemirrorInsertValueHints"; import { sqlBlockFoldService } from "@/lib/editor/codemirrorSqlBlockFolding"; import { focusEditorView } from "@/lib/editor/queryEditorFocus"; import { createDbxCodeMirrorSqlDialect, type CodeMirrorSqlDialectName } from "@/lib/editor/codemirrorSqlDialect"; @@ -727,8 +727,6 @@ const queryEditorAppearanceSettings = computed(() => { wordWrap: settings.wordWrap, vimModeEnabled: settings.vimModeEnabled, autoCloseBrackets: settings.autoCloseBrackets, - showCurrentStatementFrame: settings.showCurrentStatementFrame, - showInsertValueHints: settings.showInsertValueHints, showLineNumbers: settings.showLineNumbers, shortcuts: settings.shortcuts, showStatementRunButtons: settings.showStatementRunButtons, @@ -2432,7 +2430,7 @@ function getInsertValueHintTableColumns(table: string, schema?: string, database function requestInsertValueHintTableColumns(table: string, schema?: string, database?: string) { if (!props.connectionId || props.database == null) return; - if (props.databaseType === "redis" || props.databaseType === "mongodb" || props.databaseType === "elasticsearch" || props.databaseType === "easysearch" || props.databaseType === "meilisearch" || props.databaseType === "victoriametrics") return; + if (!supportsInsertValueHints(props.databaseType)) return; const cacheKey = insertHintCacheKey({ name: table, schema, database }); const hasCachedColumns = props.databaseType === "sqlserver" ? cachedInsertValueHintColumnsByTable.has(cacheKey) : cachedColumnsByTable.has(cacheKey); if (hasCachedColumns || pendingInsertValueHintColumnLoads.has(cacheKey)) return; @@ -5768,8 +5766,7 @@ onMounted(async () => { sqlSignatureComp.of(buildSqlSignatureExtension()), diagnosticComp.of(buildSqlDiagnosticExtension()), createInsertValueHintsExtension({ - isEnabled: () => - settingsStore.editorSettings.showInsertValueHints && props.databaseType !== "redis" && props.databaseType !== "mongodb" && props.databaseType !== "elasticsearch" && props.databaseType !== "easysearch" && props.databaseType !== "meilisearch" && props.databaseType !== "victoriametrics", + isEnabled: () => settingsStore.editorSettings.showInsertValueHints && supportsInsertValueHints(props.databaseType), getTableColumns: getInsertValueHintTableColumns, requestTableColumns: requestInsertValueHintTableColumns, getDialectId: () => resolveSqlDialectId({ databaseType: props.databaseType, dialect: sqlBehaviorDialect() }), @@ -6670,7 +6667,7 @@ defineExpose({ shouldBlockExecutionShortcut, requestExecute, requestExecuteInNewResultTab, -requestPreviewChanges, + requestPreviewChanges, captureExecutionSnapshot, pasteClipboardAsSqlInCondition, focusStatementRange, diff --git a/apps/desktop/src/components/layout/EditorToolbar.vue b/apps/desktop/src/components/layout/EditorToolbar.vue index 6468b84e83..4398d2a5bf 100644 --- a/apps/desktop/src/components/layout/EditorToolbar.vue +++ b/apps/desktop/src/components/layout/EditorToolbar.vue @@ -1,7 +1,8 @@