From d437cd46f5cf03a327cbef412b0d71f086e8d23c Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Thu, 26 Nov 2026 17:08:47 +0800 Subject: [PATCH] fix(settings): keep the annotation colour of imported color schemes (#6130) Importing a color scheme mapped only DEFAULT_METADATA to the annotation colour. Java annotations use ANNOTATION_NAME_ATTRIBUTES, which the bundled Default and Darcula schemes set themselves, so a scheme based on them that only changes DEFAULT_METADATA lost its annotation colour on import. The importer now reads ANNOTATION_NAME_ATTRIBUTES ahead of DEFAULT_METADATA, applies the parent's value when a Default- or Darcula-based file leaves it out, and exports the colour under that key. Fixes #6108 --- src/platform/icls.test.ts | 33 +++++++++++++++++++++++++++++++++ src/platform/icls.ts | 8 ++++++++ 2 files changed, 41 insertions(+) diff --git a/src/platform/icls.test.ts b/src/platform/icls.test.ts index 5f224ae88..cbd520414 100644 --- a/src/platform/icls.test.ts +++ b/src/platform/icls.test.ts @@ -712,3 +712,36 @@ describe(".icls schemes", () => { } }); }); + +describe("annotation colour (#6108)", () => { + const opt = (name: string, value: string) => + ``; + const scheme = (parent: string | null, ...options: string[]) => + parseIcls( + `${options.join("")}`, + ).scheme; + + it.each([ + ["Default", "#808000"], + ["Darcula", "#bbb529"], + ])("keeps %s's own annotation colour when the file only changes DEFAULT_METADATA", (parent, colour) => { + // IntelliJ shows Java annotations with the parent's ANNOTATION_NAME_ATTRIBUTES, not the file's default. + expect(scheme(parent, opt("DEFAULT_METADATA", "1d8711")).attributes.metadata?.foreground).toBe(colour); + }); + + it("takes the file's annotation key over its DEFAULT_METADATA", () => { + const s = scheme("Default", opt("DEFAULT_METADATA", "1d8711"), opt("ANNOTATION_NAME_ATTRIBUTES", "9e880d")); + expect(s.attributes.metadata?.foreground).toBe("#9e880d"); + }); + + it("uses DEFAULT_METADATA without a bundled parent", () => { + expect(scheme(null, opt("DEFAULT_METADATA", "1d8711")).attributes.metadata?.foreground).toBe("#1d8711"); + }); + + it("exports the annotation colour under the annotation key, so it survives a re-import", () => { + const imported = scheme("Default", opt("ANNOTATION_NAME_ATTRIBUTES", "9e880d")); + const xml = exportIcls("custom-a", { "custom-a": imported }); + expect(xml).toContain('