Skip to content

armgit / dbx

Public Imported from GitHub
0

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。

fix(editor): apply configured font to the autocomplete popup

lxk9556894bb026e7f
diff --git a/apps/desktop/src/App.vue b/apps/desktop/src/App.vue
index 1d5fc5be3e..5719f4268e 100644
--- a/apps/desktop/src/App.vue
+++ b/apps/desktop/src/App.vue
@@ -167,7 +167,7 @@ import type { DriverStoreFocus, DriverStoreTab } from "@/lib/connection/agentDri
import { safeLocalStorageGet, safeLocalStorageSet } from "@/lib/backend/safeStorage";
import { webPath } from "@/lib/common/webPath";
import { eventTargetAllowsNativeClipboard, shouldBlockAppNativeSelectAll } from "@/lib/common/clipboard";
-import { APP_FONT_SANS_CSS_VAR, DATA_GRID_FONT_FAMILY_CSS_VAR, DEFAULT_DATA_GRID_FONT_FAMILY, DEFAULT_MONO_FONT_FAMILY, DEFAULT_UI_FONT_FAMILY, FONT_MONO_CSS_VAR } from "@/lib/app/appFonts";
+import { APP_FONT_SANS_CSS_VAR, DATA_GRID_FONT_FAMILY_CSS_VAR, DEFAULT_DATA_GRID_FONT_FAMILY, DEFAULT_MONO_FONT_FAMILY, DEFAULT_UI_FONT_FAMILY, EDITOR_FONT_FAMILY_CSS_VAR, FONT_MONO_CSS_VAR } from "@/lib/app/appFonts";
import { DATA_GRID_TYPE_COLOR_KEYS, dataGridTypeColorCssVar, resolveActiveDataGridTypeColors } from "@/lib/dataGrid/dataGridTypeColorScheme";
import { rankSavedSqlHistory } from "@/lib/savedSql/savedSqlHistory";
import { useUiFontFamilyPreview } from "@/composables/useUiFontFamilyPreview";
@@ -1706,7 +1706,9 @@ function applyUiFontFamily(fontFamily: string, options?: { debouncePluginBumpMs?
// Mirrors the editor font onto the global mono token so host mono surfaces and
// plugin sandboxes (via the plugin bridge's token push) follow the same setting.
function applyMonoFontFamily(fontFamily: string) {
- writeRootToken(FONT_MONO_CSS_VAR, fontFamily || DEFAULT_MONO_FONT_FAMILY);
+ const value = fontFamily || DEFAULT_MONO_FONT_FAMILY;
+ writeRootToken(FONT_MONO_CSS_VAR, value);
+ writeRootToken(EDITOR_FONT_FAMILY_CSS_VAR, value);
}
function applyDataGridFontFamily(fontFamily: string) {
diff --git a/apps/desktop/src/lib/__tests__/editorThemes.spec.ts b/apps/desktop/src/lib/__tests__/editorThemes.spec.ts
index 48ef2b03aa..7e0fb054c3 100644
--- a/apps/desktop/src/lib/__tests__/editorThemes.spec.ts
+++ b/apps/desktop/src/lib/__tests__/editorThemes.spec.ts
@@ -216,15 +216,19 @@ describe("SQL completion theme", () => {
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", () => {
+ it("renders the info popup and completion list items 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.
+ // variable set on its own rule. Autocomplete ul and completionDetail also
+ // need the variable set so details and items do not fall back to monospace.
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-tooltip.cm-completionInfo *"]).toMatchObject({ fontFamily: "inherit" });
expect(rules[".cm-completionLabel"]).toMatchObject({ fontFamily: editorFont });
+ expect(rules[".cm-completionDetail"]).toMatchObject({ fontFamily: editorFont });
+ expect(rules[".cm-tooltip.cm-tooltip-autocomplete > ul"]).toMatchObject({ fontFamily: editorFont });
});
it("keeps completion labels ahead of long detail text", () => {
diff --git a/apps/desktop/src/lib/app/appFonts.ts b/apps/desktop/src/lib/app/appFonts.ts
index 97cddac739..7c487bbcb4 100644
--- a/apps/desktop/src/lib/app/appFonts.ts
+++ b/apps/desktop/src/lib/app/appFonts.ts
@@ -1,5 +1,6 @@
export const APP_FONT_SANS_CSS_VAR = "--font-sans";
export const FONT_MONO_CSS_VAR = "--font-mono";
+export const EDITOR_FONT_FAMILY_CSS_VAR = "--dbx-editor-font-family";
export const DATA_GRID_FONT_FAMILY_CSS_VAR = "--dbx-data-grid-font-family";
export const DEFAULT_UI_FONT_FAMILY = `"Geist Variable", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif`;
diff --git a/apps/desktop/src/lib/editor/editorThemes.ts b/apps/desktop/src/lib/editor/editorThemes.ts
index 300a1f453e..418e934548 100644
--- a/apps/desktop/src/lib/editor/editorThemes.ts
+++ b/apps/desktop/src/lib/editor/editorThemes.ts
@@ -988,6 +988,7 @@ export function buildSqlCompletionThemeRules(): CodeMirrorStyleSpec {
boxSizing: "border-box",
},
".cm-tooltip.cm-tooltip-autocomplete > ul": {
+ fontFamily: `var(${EDITOR_FONT_FAMILY_CSS_VAR}, var(--font-mono, monospace))`,
maxHeight: "min(280px, calc(100vh - 32px))",
minWidth: "min(280px, calc(100vw - 24px))",
maxWidth: "inherit",
@@ -1119,6 +1120,7 @@ export function buildSqlCompletionThemeRules(): CodeMirrorStyleSpec {
},
".cm-completionDetail": {
color: colorMixValue("var(--muted-foreground)", "color-mix(in oklch, var(--popover-foreground) 68%, var(--popover))"),
+ fontFamily: `var(${EDITOR_FONT_FAMILY_CSS_VAR}, var(--font-mono, monospace))`,
fontSize: `clamp(11px, calc(var(${EDITOR_FONT_SIZE_CSS_VAR}, 13px) - 1px), 13px)`,
fontWeight: "500",
fontStyle: "normal",
@@ -1136,6 +1138,9 @@ export function buildSqlCompletionThemeRules(): CodeMirrorStyleSpec {
overflowWrap: "anywhere",
zIndex: "10000",
},
+ ".cm-tooltip.cm-completionInfo *": {
+ fontFamily: "inherit",
+ },
};
}