Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gentle-comments-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"hunkdiff": patch
---

Honor custom comment syntax colors in Pierre-highlighted diffs.
6 changes: 4 additions & 2 deletions src/ui/diff/pierre.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -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,
};
Expand All @@ -659,6 +659,7 @@ describe("Pierre diff rows", () => {
keyword: "#112233",
function: "#223344",
string: "#334455",
comment: "#445566",
},
});
const highlighted = await loadHighlightedDiff(file, theme.appearance);
Expand All @@ -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");
}
});

Expand Down
2 changes: 2 additions & 0 deletions src/ui/diff/pierre.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ const RESERVED_PIERRE_TOKEN_COLORS = {
"#ffca00": "default",
"#68cdf2": "number",
"#5ecc71": "string",
"#737373": "comment",
"#ffa359": "property",
"#a3a3a3": "variable",
"#08c0ef": "operator",
Expand All @@ -243,6 +244,7 @@ const RESERVED_PIERRE_TOKEN_COLORS = {
"#d5a910": "default",
"#1ca1c7": "number",
"#199f43": "string",
"#737373": "comment",
"#d47628": "property",
"#a3a3a3": "variable",
"#08c0ef": "operator",
Expand Down