From 5685e060be33d3e20ee74df80c883c5816330885 Mon Sep 17 00:00:00 2001
From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com>
Date: Thu, 26 Nov 2026 18:20:31 +0800
Subject: [PATCH] fix(plugins): keep the annotation colour of a theme plugin's
color scheme
A theme plugin's .icls mapped DEFAULT_METADATA onto the annotation colour
and ignored ANNOTATION_NAME_ATTRIBUTES, so a scheme that only changed
DEFAULT_METADATA repainted Java annotations, which take the annotation
key (Darcula's own when the file has none).
---
.../__tests__/intellijThemeAnnotation.test.ts | 27 +++++++++++++++++++
src/features/plugins/intellijTheme.ts | 7 +++--
2 files changed, 30 insertions(+), 4 deletions(-)
create mode 100644 src/features/plugins/__tests__/intellijThemeAnnotation.test.ts
diff --git a/src/features/plugins/__tests__/intellijThemeAnnotation.test.ts b/src/features/plugins/__tests__/intellijThemeAnnotation.test.ts
new file mode 100644
index 0000000000..2ac32f7d34
--- /dev/null
+++ b/src/features/plugins/__tests__/intellijThemeAnnotation.test.ts
@@ -0,0 +1,27 @@
+import { describe, expect, it } from "vitest";
+import { convertIcls } from "../intellijTheme";
+
+const opt = (name: string, value: string) =>
+ ``;
+const scheme = (parent: string, ...options: string[]) =>
+ `${options.join("")}`;
+
+describe("annotation colour of a theme plugin's scheme (#6108)", () => {
+ it("keeps Darcula's annotation colour when the file only changes DEFAULT_METADATA", () => {
+ const { tokens } = convertIcls(scheme("Darcula", opt("DEFAULT_METADATA", "1d8711")));
+ expect(tokens["--syn-annotation"]).toBe("#bbb529");
+ expect(tokens["--syn-decorator"]).toBe("#1d8711");
+ });
+
+ it("takes the file's annotation key for annotations", () => {
+ const { tokens } = convertIcls(
+ scheme("Darcula", opt("DEFAULT_METADATA", "1d8711"), opt("ANNOTATION_NAME_ATTRIBUTES", "9e880d")),
+ );
+ expect(tokens["--syn-annotation"]).toBe("#9e880d");
+ });
+
+ it("leaves a light parent's annotation colour to the base theme", () => {
+ const { tokens } = convertIcls(scheme("Default", opt("DEFAULT_METADATA", "1d8711")));
+ expect(tokens["--syn-annotation"]).toBeUndefined();
+ });
+});
diff --git a/src/features/plugins/intellijTheme.ts b/src/features/plugins/intellijTheme.ts
index 8951adf4b7..dd786c840e 100644
--- a/src/features/plugins/intellijTheme.ts
+++ b/src/features/plugins/intellijTheme.ts
@@ -163,10 +163,9 @@ export const ICLS_ATTRIBUTES: Record> = {
DEFAULT_PARAMETER: [["FOREGROUND", "--syn-param"]],
DEFAULT_GLOBAL_VARIABLE: [["FOREGROUND", "--syn-global"]],
DEFAULT_PREDEFINED_SYMBOL: [["FOREGROUND", "--syn-builtin"]],
- DEFAULT_METADATA: [
- ["FOREGROUND", "--syn-annotation"],
- ["FOREGROUND", "--syn-decorator"],
- ],
+ // Java annotations take the scheme's (or its parent's) annotation key, not DEFAULT_METADATA.
+ ANNOTATION_NAME_ATTRIBUTES: [["FOREGROUND", "--syn-annotation"]],
+ DEFAULT_METADATA: [["FOREGROUND", "--syn-decorator"]],
DEFAULT_OPERATION_SIGN: [["FOREGROUND", "--syn-punct"]],
DEFAULT_VALID_STRING_ESCAPE: [["FOREGROUND", "--syn-escape"]],
DEFAULT_TAG: [["FOREGROUND", "--syn-tag"]],