fix(editor): use the configured font in the completion info popup

This commit is contained in:
BASIL K AJI authored and GitHub committed 2026-10-08 11:36:30 +08:00
1 parent 2c48928936
commit 46366b00ae
3 files changed
+16 -2

No files matched your search

+3 -1
View File
@@ -32,6 +32,7 @@ import { useSavedSqlStore } from "@/stores/savedSqlStore";
import { usePromptTemplateStore } from "@/stores/promptTemplateStore"; import { usePromptTemplateStore } from "@/stores/promptTemplateStore";
import { useToast } from "@/composables/useToast"; import { useToast } from "@/composables/useToast";
import { useTheme } from "@/composables/useTheme"; import { useTheme } from "@/composables/useTheme";
import { useEditorFontFamilyStyle } from "@/composables/useEditorFontFamilyStyle";
import { canDownloadAndInstallUpdate, useAppUpdater } from "@/composables/useAppUpdater"; import { canDownloadAndInstallUpdate, useAppUpdater } from "@/composables/useAppUpdater";
import { useMcpUpdateBadge } from "@/composables/useMcpUpdateBadge"; import { useMcpUpdateBadge } from "@/composables/useMcpUpdateBadge";
import { useComponentUpdates, type ComponentUpdateCategory } from "@/composables/useComponentUpdates"; import { useComponentUpdates, type ComponentUpdateCategory } from "@/composables/useComponentUpdates";
@@ -234,6 +235,7 @@ const queryStore = useQueryStore();
const navigationStore = useNavigationStore(); const navigationStore = useNavigationStore();
const settingsStore = useSettingsStore(); const settingsStore = useSettingsStore();
const { active: appBackgroundActive, backgroundObjectUrl: appBackgroundObjectUrl, backgroundImageStyle: appBackgroundImageStyle } = useBackgroundImage(settingsStore); const { active: appBackgroundActive, backgroundObjectUrl: appBackgroundObjectUrl, backgroundImageStyle: appBackgroundImageStyle } = useBackgroundImage(settingsStore);
const editorFontFamilyStyle = useEditorFontFamilyStyle();
const { uiFontFamilyPreview } = useUiFontFamilyPreview(); const { uiFontFamilyPreview } = useUiFontFamilyPreview();
const savedSqlStore = useSavedSqlStore(); const savedSqlStore = useSavedSqlStore();
const promptTemplateStore = usePromptTemplateStore(); const promptTemplateStore = usePromptTemplateStore();
@@ -5382,7 +5384,7 @@ onUnmounted(() => {
@saved="onQueryEditorObjectSourceSaved" @saved="onQueryEditorObjectSourceSaved"
/> />
</TooltipProvider> </TooltipProvider>
<div id="dbx-query-editor-tooltip-root" class="fixed left-0 top-0 z-[70] h-0 w-0 overflow-visible" /> <div id="dbx-query-editor-tooltip-root" class="fixed left-0 top-0 z-[70] h-0 w-0 overflow-visible" :style="editorFontFamilyStyle" />
</div> </div>
</template> </template>
+12 -1
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest"; import { describe, expect, it } from "vitest";
import { buildEditorFontThemeRules, buildSqlCompletionThemeRules, editorDiagnosticColors, editorThemeAppearanceFor, IDE_EDITOR_THEMES, loadEditorTheme, resolveCustomThemeBackgrounds, resolveEditorTheme, SQL_BUILTIN_HIGHLIGHT_TAG } from "@/lib/editor/editorThemes"; import { buildEditorFontThemeRules, buildSqlCompletionThemeRules, EDITOR_FONT_FAMILY_CSS_VAR, editorDiagnosticColors, editorThemeAppearanceFor, IDE_EDITOR_THEMES, loadEditorTheme, resolveCustomThemeBackgrounds, resolveEditorTheme, SQL_BUILTIN_HIGHLIGHT_TAG } from "@/lib/editor/editorThemes";
import { DEFAULT_APP_CUSTOM_UI_COLORS, wcagContrastRatio, type AppThemePalette } from "@/lib/app/appTheme"; import { DEFAULT_APP_CUSTOM_UI_COLORS, wcagContrastRatio, type AppThemePalette } from "@/lib/app/appTheme";
import { DEFAULT_CUSTOM_THEME_COLORS, type CustomThemeColors, type EditorTheme } from "@/stores/settingsStore"; import { DEFAULT_CUSTOM_THEME_COLORS, type CustomThemeColors, type EditorTheme } from "@/stores/settingsStore";
import { createDbxCodeMirrorSqlDialect } from "@/lib/editor/codemirrorSqlDialect"; import { createDbxCodeMirrorSqlDialect } from "@/lib/editor/codemirrorSqlDialect";
@@ -216,6 +216,17 @@ describe("SQL completion theme", () => {
expect(rules[".cm-tooltip.cm-tooltip-autocomplete > ul > li"]).toMatchObject({ borderRadius: "var(--dbx-radius-sm)" }); expect(rules[".cm-tooltip.cm-tooltip-autocomplete > ul > li"]).toMatchObject({ borderRadius: "var(--dbx-radius-sm)" });
}); });
it("renders the info popup in the configured editor font", () => {
// The info popup is a sibling tooltip rather than a child of the
// autocomplete tooltip, so it inherits nothing from it and needs the
// variable set on its own rule.
const rules = buildSqlCompletionThemeRules();
const editorFont = `var(${EDITOR_FONT_FAMILY_CSS_VAR}, var(--font-mono, monospace))`;
expect(rules[".cm-tooltip.cm-completionInfo"]).toMatchObject({ fontFamily: editorFont });
expect(rules[".cm-completionLabel"]).toMatchObject({ fontFamily: editorFont });
});
it("keeps completion labels ahead of long detail text", () => { it("keeps completion labels ahead of long detail text", () => {
const rules = buildSqlCompletionThemeRules(); const rules = buildSqlCompletionThemeRules();
@@ -1131,6 +1131,7 @@ export function buildSqlCompletionThemeRules(): CodeMirrorStyleSpec {
whiteSpace: "nowrap", whiteSpace: "nowrap",
}, },
".cm-tooltip.cm-completionInfo": { ".cm-tooltip.cm-completionInfo": {
fontFamily: `var(${EDITOR_FONT_FAMILY_CSS_VAR}, var(--font-mono, monospace))`,
maxWidth: "min(420px, calc(100vw - 24px))", maxWidth: "min(420px, calc(100vw - 24px))",
overflowWrap: "anywhere", overflowWrap: "anywhere",
zIndex: "10000", zIndex: "10000",