fix(themes): preserve language-specific ICLS styles (#1457)

Importing a PhpStorm .icls applied Java/Kotlin keys and PHP-only colours to every language, so PHP variables, strings and punctuation came out wrong. Java, Kotlin and PHP attributes are now kept per language (Color Scheme lists them under their own nodes, and editors scope them by data-language), explicit attribute inheritance is resolved, an explicit TextAttributes value resets omitted bold/italic, the light/dark parent follows the scheme's background, and PHP classes, method declarations, fields, brackets and separators get their own tags. Selecting a language attribute in Settings previews that language's colours.

Co-authored-by: marianomd <[email protected]>
Цей коміт міститься в:
Mariano Dupontтаmarianomd authored and GitHub committed 2026-11-05 12:59:38 +08:00
1 джерело 75c4ca0be8
коміт 8dedf5e73b
12 files changed
+318 -37

No files matched your search

+12 -3
Переглянути файл
@@ -55,11 +55,15 @@ function buildTree(): Node[] {
const TREE = buildTree();
/** CSS custom properties of a scheme plus pending overrides (for the preview). */
/**
* CSS custom properties of a scheme plus pending overrides (for the preview); with
* `language`, that language's own colours on top, as its editors show them.
*/
function previewVars(
id: string,
o: Record<string, TextAttributesOverride> | undefined,
customs: CustomColorSchemes,
language?: string,
): CSSProperties {
const vars: Record<string, string> = {};
const tokens = resolvedSchemeTokens(id, customs);
@@ -74,6 +78,10 @@ function previewVars(
vars[k] = v;
vars["--bg-editor"] = tokens.get("--bg-editor") ?? tokens.get("--bg-island") ?? "";
for (const [key, value] of overrideDeclarations(o)) vars[key] = value;
if (language) {
for (const [key, value] of overrideDeclarations(customs[id]?.attributes, language)) vars[key] = value;
for (const [key, value] of overrideDeclarations(o, language)) vars[key] = value;
}
return vars as CSSProperties;
}
@@ -276,9 +284,10 @@ function ColorSchemePage() {
const id = effectiveScheme(scheme, undefined, customs);
const mine = overrides?.[id];
const attr = ATTRIBUTES.find((a) => a.id === selected);
const language = attr?.language;
const vars = useMemo(
() => ({ ...previewVars(id, mine, customs), ...fontWeightVars(weight, boldFontWeight) }) as CSSProperties,
[id, mine, customs, weight, boldFontWeight],
() => ({ ...previewVars(id, mine, customs, language), ...fontWeightVars(weight, boldFontWeight) }) as CSSProperties,
[id, mine, customs, language, weight, boldFontWeight],
);
const update = (attrId: string, v: TextAttributesOverride | undefined) => {
const next: Overrides = { ...(overrides ?? {}) };