From 68ffce63409aa402e91384a3a6acbb7ec927c8ef Mon Sep 17 00:00:00 2001 From: "G. Bodenschatz" Date: Sat, 5 Dec 2026 15:34:54 +0100 Subject: [PATCH] fix(editor): paint diff panes and the colour scheme list with the editor scheme's colours, not the UI theme's (#8227) With an editor colour scheme of the other brightness than the UI theme, the diff panes kept the theme's --bg-app / --fg while their syntax colours came from the scheme, and the Color Scheme page applied every UI token of the scheme to its attribute list. The diff viewer now uses --bg-editor, --fg-editor and --bg-editor-gutter like the editor, the strip between panes follows the editor surface, and the scheme page gives its list only the scheme's editor tokens. Closes #8160 Co-authored-by: coding46 <1724196+coding46@users.noreply.github.com> --- src/features/settings/pages/editor/ColorSchemeBody.tsx | 9 ++++++++- src/features/vcs/DiffEditor.module.css | 3 ++- src/features/vcs/cm.ts | 10 ++++++---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/features/settings/pages/editor/ColorSchemeBody.tsx b/src/features/settings/pages/editor/ColorSchemeBody.tsx index 6f8c368a0a..a7b1b31bfb 100644 --- a/src/features/settings/pages/editor/ColorSchemeBody.tsx +++ b/src/features/settings/pages/editor/ColorSchemeBody.tsx @@ -1852,10 +1852,17 @@ export function ColorSchemePage({ if (scopes[0] === "Console Colors" && next["--bg-console"]) next["--bg-editor"] = next["--bg-console"]; return next; }, [id, mine, customs, language, weight, boldFontWeight, scopes, redGreen, themeTokens]); + // The attribute list and its controls sit on the UI's surface: they take the scheme's editor + // tokens, not its UI ones (`--fg-strong`, `--bg-app`, `--border-*`), which a scheme other than + // the theme's own would turn into unreadable text on the theme's background. const baseVars = useMemo( () => ({ - ...previewVars(id, mine, customs, undefined, redGreen, themeTokens), + ...Object.fromEntries( + Object.entries(previewVars(id, mine, customs, undefined, redGreen, themeTokens)).filter( + ([key]) => !/^--(?:fg|bg|border)-(?!editor)/.test(key), + ), + ), ...fontWeightVars(weight, boldFontWeight), }) as CSSProperties, [id, mine, customs, weight, boldFontWeight, redGreen, themeTokens], diff --git a/src/features/vcs/DiffEditor.module.css b/src/features/vcs/DiffEditor.module.css index 02fe16656c..be2445eb7b 100644 --- a/src/features/vcs/DiffEditor.module.css +++ b/src/features/vcs/DiffEditor.module.css @@ -362,7 +362,8 @@ flex: none; width: 30px; overflow: hidden; - background: var(--bg-app); + /* Between the two panes: their surface, which a colour scheme changes. */ + background: var(--bg-editor, var(--bg-app)); border-left: 1px solid var(--border); border-right: 1px solid var(--border); cursor: col-resize; diff --git a/src/features/vcs/cm.ts b/src/features/vcs/cm.ts index 5b8deb5ffb..92fe3ad485 100644 --- a/src/features/vcs/cm.ts +++ b/src/features/vcs/cm.ts @@ -403,8 +403,10 @@ export const viewerTheme = EditorView.theme( ...overviewStyles, "&.cm-editor": { height: "100%" }, "&": { - backgroundColor: "var(--bg-app)", - color: "var(--fg)", + // The editor colour scheme's surface and text, as the regular editor (a scheme other than + // the theme's own changes these, not the UI's `--bg-app` / `--fg`). + backgroundColor: "var(--bg-editor, var(--bg-island, var(--bg-app)))", + color: "var(--fg-editor, var(--fg))", fontSize: "var(--openidea-editor-font-size, var(--fs-code))", ...findLocals, }, @@ -436,7 +438,7 @@ export const viewerTheme = EditorView.theme( }, ".cm-activeLine": { backgroundColor: "var(--bg-current-line)" }, ".cm-gutters": { - backgroundColor: "var(--bg-app)", + backgroundColor: "var(--bg-editor-gutter, var(--bg-editor, var(--bg-island, var(--bg-app))))", color: "var(--fg-gutter)", border: "none", }, @@ -473,7 +475,7 @@ export const viewerTheme = EditorView.theme( }, { [`.cm-diffGutter-fine.cm-diffGutter-${k}`]: { - backgroundColor: `color-mix(in srgb, var(--diff-${k}) 40%, var(--bg-app))`, + backgroundColor: `color-mix(in srgb, var(--diff-${k}) 40%, var(--bg-editor, var(--bg-app)))`, }, }, ]),