From fa7fcd0d90600f5d0adb93a83ba52f67b79f3290 Mon Sep 17 00:00:00 2001 From: LU XIANGRUI <1078666705@qq.com> Date: Sat, 21 Nov 2026 15:48:07 +0900 Subject: [PATCH] fix(color-scheme): import PyCharm's function call, class and f-string colours (#4965) Importing a PyCharm color scheme skipped eight PyCharm Python keys (PY.FUNCTION_CALL, PY.CLASS_DEFINITION, PY.PARAMETER, PY.LOCAL_VARIABLE, PY.TYPE_PARAMETER, PY.INVALID_STRING_ESCAPE, PY.FSTRING_FRAGMENT_BRACES, PY.FSTRING_FORMAT_SPEC_NUMBER), so Python calls took the shared call colour. They now map to the existing Python attributes and export under PyCharm's keys; files exported earlier under OPENIDEA_ names still import. Co-authored-by: wildcatDownstairs <26499420+wildcatDownstairs@users.noreply.github.com> --- src/platform/icls.test.ts | 36 ++++++++++++++++++++++++++++++++++++ src/platform/icls.ts | 20 ++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/src/platform/icls.test.ts b/src/platform/icls.test.ts index 44e3cf025..31d670784 100644 --- a/src/platform/icls.test.ts +++ b/src/platform/icls.test.ts @@ -398,6 +398,42 @@ describe(".icls schemes", () => { for (const [name, value] of names) expect(attrs[name]?.foreground).toBe(`#${value}`); }); + it("imports PyCharm's function call, class, parameter and f-string keys and exports them by those keys", () => { + const keys = [ + ["PY.FUNCTION_CALL", "pyFunctionCall", "d56075"], + ["PY.CLASS_DEFINITION", "pyClassDefinition", "7bcbff"], + ["PY.PARAMETER", "pyParameter", "101010"], + ["PY.LOCAL_VARIABLE", "pyLocalVariable", "202020"], + ["PY.TYPE_PARAMETER", "pyTypeParameter", "303030"], + ["PY.INVALID_STRING_ESCAPE", "pyInvalidEscape", "404040"], + ["PY.FSTRING_FRAGMENT_BRACES", "pyFString", "e89c45"], + ["PY.FSTRING_FORMAT_SPEC_NUMBER", "pyFormat", "505050"], + ] as const; + const xml = `${keys + .map( + ([key, , value]) => + ``, + ) + .join("")} + `; + const { scheme, skipped } = parseIcls(xml); + expect(skipped).toBe(0); + for (const [, id, value] of keys) expect(scheme.attributes[id]?.foreground).toBe(`#${value}`); + // A WebStorm function colour still sets the shared call colour; Python calls keep PyCharm's. + expect(scheme.attributes.functionCall?.foreground).toBe("#6dacff"); + const { id, customs } = importScheme({}, scheme); + const exported = exportIcls(id, customs); + for (const [key] of keys) expect(exported).toContain(`name="${key}"`); + expect(exported).not.toContain('name="PY.STRING.F"'); + }); + + it("still reads Python attributes that earlier versions exported under OPENIDEA_ names", () => { + const xml = + ''; + expect(parseIcls(xml).scheme.attributes.pyFunctionCall?.foreground).toBe("#d56075"); + }); + it("imports the Python f-string colour", () => { const xml = '