From 5657dbd3e3dbbd004caead3c3a0c4232d04a39cd Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Wed, 18 Nov 2026 08:45:40 +0800 Subject: [PATCH] fix(color-scheme): an unticked Foreground keeps the text visible (#4065) Unticking Foreground wrote the cleared colour, transparent, into the attribute's colour variable, so its tokens became invisible. A cleared foreground now falls back to the default text colour; cleared backgrounds and effects stay transparent. Refs #4059 --- src/platform/colorScheme.test.ts | 3 +++ src/platform/colorScheme.ts | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/platform/colorScheme.test.ts b/src/platform/colorScheme.test.ts index 06ff7edcd..13b4b7168 100644 --- a/src/platform/colorScheme.test.ts +++ b/src/platform/colorScheme.test.ts @@ -169,6 +169,9 @@ describe("color schemes", () => { expect(regular).toContain("--syn-keyword-bold: var(--fw-code, 400) !important"); const cleared = schemeCss("theme-default", { light: { keyword: { background: CLEAR_COLOR } } }, root); expect(cleared).toContain("--syn-keyword-bg: transparent !important"); + // An unticked Foreground falls back to the default text colour instead of hiding the text. + const noForeground = schemeCss("theme-default", { light: { predefined: { foreground: CLEAR_COLOR } } }, root); + expect(noForeground).toContain("--syn-builtin: var(--fg-editor) !important"); const upright = schemeCss("theme-default", { light: { staticSymbol: { italic: false } } }, root); expect(upright).toContain("--syn-static-italic: normal !important"); const pythonItalic = schemeCss("theme-default", { light: { pyStaticSymbol: { italic: true } } }, root); diff --git a/src/platform/colorScheme.ts b/src/platform/colorScheme.ts index 0cf264d0a..6d8714ef4 100644 --- a/src/platform/colorScheme.ts +++ b/src/platform/colorScheme.ts @@ -605,9 +605,11 @@ export function overrideDeclarations( const o = overrides[attr.id]; if (!o) continue; if (setOrCleared(o.foreground) && attr.fg) { - out.push([attr.fg, o.foreground]); + // No foreground means the default text colour, not invisible text. + const fg = o.foreground === CLEAR_COLOR && attr.id !== "text" ? "var(--fg-editor)" : o.foreground!; + out.push([attr.fg, fg]); // Terminal prefers `--terminal-ansi-*`; keep it in sync with console `--ansi-*`. - if (attr.fg.startsWith("--ansi-")) out.push([`--terminal-ansi-${attr.fg.slice("--ansi-".length)}`, o.foreground]); + if (attr.fg.startsWith("--ansi-")) out.push([`--terminal-ansi-${attr.fg.slice("--ansi-".length)}`, fg]); } if (setOrCleared(o.background) && attr.bg) out.push([attr.bg, o.background]); if (setOrCleared(o.effectColor) && attr.effect) out.push([attr.effect, o.effectColor]);