From 8c1d9671fa2db8a90ab6f2db5949c5b98c1d9b04 Mon Sep 17 00:00:00 2001 From: Hamel Desai Date: Fri, 17 Jul 2026 08:50:02 -0400 Subject: [PATCH] fix(ui): honor custom comment colors --- .changeset/gentle-comments-glow.md | 5 +++++ src/ui/diff/pierre.test.ts | 6 ++++-- src/ui/diff/pierre.ts | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 .changeset/gentle-comments-glow.md diff --git a/.changeset/gentle-comments-glow.md b/.changeset/gentle-comments-glow.md new file mode 100644 index 00000000..f7dfa251 --- /dev/null +++ b/.changeset/gentle-comments-glow.md @@ -0,0 +1,5 @@ +--- +"hunkdiff": patch +--- + +Honor custom comment syntax colors in Pierre-highlighted diffs. diff --git a/src/ui/diff/pierre.test.ts b/src/ui/diff/pierre.test.ts index b4d56614..8e9f25ef 100644 --- a/src/ui/diff/pierre.test.ts +++ b/src/ui/diff/pierre.test.ts @@ -636,7 +636,7 @@ describe("Pierre diff rows", () => { { name: "syntax.ts", contents: - 'const a = 1;\nexport function compute(): number {\n return 42;\n}\nconst greeting = "hello";\n', + 'const a = 1;\nexport function compute(): number {\n return 42;\n}\nconst greeting = "hello";\n// visible comment\n', cacheKey: "syntax-after", }, { context: 3 }, @@ -647,7 +647,7 @@ describe("Pierre diff rows", () => { path: "syntax.ts", patch: "", language: "typescript", - stats: { additions: 4, deletions: 0 }, + stats: { additions: 5, deletions: 0 }, metadata, agent: null, }; @@ -659,6 +659,7 @@ describe("Pierre diff rows", () => { keyword: "#112233", function: "#223344", string: "#334455", + comment: "#445566", }, }); const highlighted = await loadHighlightedDiff(file, theme.appearance); @@ -672,6 +673,7 @@ describe("Pierre diff rows", () => { expect(spans.find((span) => span.text.includes("function"))?.fg).toBe("#112233"); expect(spans.find((span) => span.text.includes("compute"))?.fg).toBe("#223344"); expect(spans.find((span) => span.text.includes('"hello"'))?.fg).toBe("#334455"); + expect(spans.find((span) => span.text.includes("visible comment"))?.fg).toBe("#445566"); } }); diff --git a/src/ui/diff/pierre.ts b/src/ui/diff/pierre.ts index 41af3497..88da8566 100644 --- a/src/ui/diff/pierre.ts +++ b/src/ui/diff/pierre.ts @@ -225,6 +225,7 @@ const RESERVED_PIERRE_TOKEN_COLORS = { "#ffca00": "default", "#68cdf2": "number", "#5ecc71": "string", + "#737373": "comment", "#ffa359": "property", "#a3a3a3": "variable", "#08c0ef": "operator", @@ -243,6 +244,7 @@ const RESERVED_PIERRE_TOKEN_COLORS = { "#d5a910": "default", "#1ca1c7": "number", "#199f43": "string", + "#737373": "comment", "#d47628": "property", "#a3a3a3": "variable", "#08c0ef": "operator",