fix(color-scheme): show Language Defaults overrides on a language's comment attributes (#7473)

A language's comment attribute (JavaScript Line comment) resolved against the scheme without the
user's Language Defaults overrides, so turning italic off under Language Defaults left the
language page's Italic checkbox checked. resolvedAttribute now applies those overrides for
language-scoped attributes, as the editor does.

The plugin-theme part of #7453 was fixed by #7474; this PR keeps the remaining fix.

Co-authored-by: OnurrUgur <[email protected]>
Цей коміт міститься в:
Onur Ugur authored and GitHub committed 2026-12-02 23:18:35 +08:00
1 джерело e985322f3a
коміт 6b038245fd
3 files changed
+25 -3

No files matched your search

+20
Переглянути файл
@@ -554,3 +554,23 @@ describe("Git colors", () => {
expect(value("colorOverrides")).toEqual({ dark: { gitLocalBranch: { bold: true } } });
});
});
describe("language-scoped comment inheritance", () => {
it("reflects Language Defaults italic override on JavaScript and TypeScript comments", () => {
_setSchemeSource(readFileSync("src/styles/tokens.css", "utf8"));
try {
act(() => {
stage("editor.colorScheme", "global", "editor.colorScheme", "light");
stage("editor.colorScheme", "global", "editor.colorOverrides", {
light: { lineComment: { italic: false } },
});
});
schemePage("editor.colorScheme.javascript-and-typescript");
const preview = screen.getByLabelText("Color scheme preview");
act(() => fireEvent.click(preview.querySelector('span[style*="--syn-comment-style"]')!));
expect(screen.getByRole("checkbox", { name: "Italic" })).not.toBeChecked();
} finally {
_setSchemeSource("");
}
});
});
+2 -2
Переглянути файл
@@ -1803,8 +1803,8 @@ export function ColorSchemePage({
const attr = ATTRIBUTES.find((a) => a.id === selected);
const language = attr?.language;
const inherited = useMemo(
() => (attr ? resolvedAttribute(id, attr.id, customs, redGreen, themeTokens) : {}),
[id, attr, customs, redGreen, themeTokens],
() => (attr ? resolvedAttribute(id, attr.id, customs, redGreen, themeTokens, mine) : {}),
[id, attr, customs, redGreen, themeTokens, mine],
);
const vars = useMemo(() => {
const next = {
+3 -1
Переглянути файл
@@ -937,12 +937,14 @@ export function resolvedAttribute(
customs: CustomColorSchemes = {},
redGreen = false,
themeTokens?: Record<string, string>,
baseOverrides?: Record<string, TextAttributesOverride>,
): TextAttributesOverride {
const attr = ATTRIBUTES.find((a) => a.id === attrId);
if (!attr) return {};
const custom = customSchemes(customs)[id];
const own = custom?.attributes[attr.id];
const vars = resolvedSchemeTokens(id, customs, redGreen, undefined, themeTokens);
// A language's attribute inherits the user's Language Defaults overrides (`lineComment`, …).
const vars = resolvedSchemeTokens(id, customs, redGreen, attr.language ? baseOverrides : undefined, themeTokens);
if (attr.language) {
const scoped = overrideDeclarations(custom?.attributes, attr.language);
for (const [key, value] of scoped) vars.set(key, value);