From e98e3157f13281bb6e36ce4f7c7b6f8de848bd32 Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Thu, 3 Sep 2026 15:01:31 +0800 Subject: [PATCH] fix(editor): pin completion icon glyph to its box --- .../src/lib/__tests__/editorThemes.spec.ts | 17 +++++++++++++++++ apps/desktop/src/lib/editor/editorThemes.ts | 10 ++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/apps/desktop/src/lib/__tests__/editorThemes.spec.ts b/apps/desktop/src/lib/__tests__/editorThemes.spec.ts index 6e1ca9e37f..cffac09a47 100644 --- a/apps/desktop/src/lib/__tests__/editorThemes.spec.ts +++ b/apps/desktop/src/lib/__tests__/editorThemes.spec.ts @@ -172,6 +172,23 @@ describe("SQL completion theme", () => { zIndex: "1", }); }); + + it("pins the completion icon glyph to its box so engines cannot clip it", () => { + const rules = buildSqlCompletionThemeRules(); + + // With `left`/`top` auto, the absolutely positioned pseudo element relies on + // engine-specific static positions inside the flex icon, and WebKit places it + // far enough left for `overflow: hidden` to cut off the left half of the glyph. + expect(rules[".cm-completionIcon:before"]).toMatchObject({ + left: "0", + top: "0", + width: "15px", + height: "15px", + maskSize: "14px 14px", + maskPosition: "center", + }); + expect(rules[".cm-completionIcon"]).toMatchObject({ width: "15px", height: "15px", overflow: "hidden" }); + }); }); describe("editor gutters", () => { diff --git a/apps/desktop/src/lib/editor/editorThemes.ts b/apps/desktop/src/lib/editor/editorThemes.ts index 80c587c6f2..e86cea4d2c 100644 --- a/apps/desktop/src/lib/editor/editorThemes.ts +++ b/apps/desktop/src/lib/editor/editorThemes.ts @@ -998,7 +998,13 @@ export function buildSqlCompletionThemeRules(): CodeMirrorStyleSpec { backgroundColor: "currentColor", content: "''", display: "block", - height: "14px", + height: "15px", + // The pseudo element must be pinned to the icon box: with `left`/`top` + // left auto, engines disagree on the static position of an absolutely + // positioned child of a flex container, and WebKit places it far enough + // left for `overflow: hidden` to cut off half the glyph. + left: "0", + top: "0", position: "absolute", WebkitMaskImage: "var(--dbx-completion-icon-mask)", WebkitMaskPosition: "center", @@ -1008,7 +1014,7 @@ export function buildSqlCompletionThemeRules(): CodeMirrorStyleSpec { maskPosition: "center", maskRepeat: "no-repeat", maskSize: "14px 14px", - width: "14px", + width: "15px", }, ".cm-completionIcon:after": { content: "'none'",