From d8d1d620f8736fd3419a21df4778b91afa88051e Mon Sep 17 00:00:00 2001 From: RestartFU Date: Tue, 28 Jul 2026 10:07:16 -0400 Subject: [PATCH 1/2] feat(diff): color file headers Co-authored-by: Codex --- src/util/unified-diff.c | 2 +- tests/test-unified-diff.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/util/unified-diff.c b/src/util/unified-diff.c index 007275e6..9b468895 100644 --- a/src/util/unified-diff.c +++ b/src/util/unified-diff.c @@ -288,7 +288,7 @@ append_file_markup (MarkupBuilder *builder, start_markup_row (builder, line->kind); g_string_append_printf ( builder->text, - "%s" + "%s" " +%u" " −%u", path, additions, deletions); diff --git a/tests/test-unified-diff.c b/tests/test-unified-diff.c index 279eb870..a961e713 100644 --- a/tests/test-unified-diff.c +++ b/tests/test-unified-diff.c @@ -97,6 +97,8 @@ test_formats_one_safe_layout (void) g_assert_nonnull (strstr (plain, "src/a.c +1 −1")); g_assert_nonnull (strstr (plain, "old ")); g_assert_nonnull (strstr (plain, "Showing first 3 of 5 rows")); + g_assert_nonnull (strstr ( + markup, "foreground=\"#ffbe6f\" weight=\"bold\">src/a.c")); g_assert_nonnull (strstr (markup, "foreground=\"#f66151\"")); } From f5d00dbe59d4ed6b9179628612e24091355b8f83 Mon Sep 17 00:00:00 2001 From: RestartFU Date: Tue, 28 Jul 2026 10:14:47 -0400 Subject: [PATCH 2/2] feat(diff): fill file headers in black Co-authored-by: Codex --- src/util/unified-diff.c | 2 ++ tests/test-unified-diff.c | 1 + 2 files changed, 3 insertions(+) diff --git a/src/util/unified-diff.c b/src/util/unified-diff.c index 9b468895..ba0cb66f 100644 --- a/src/util/unified-diff.c +++ b/src/util/unified-diff.c @@ -222,6 +222,8 @@ escaped_display_text (const char *text) const char * xd_diff_line_background (XdDiffLineKind kind) { + if (kind == XD_DIFF_LINE_FILE) + return "#000000"; if (kind == XD_DIFF_LINE_ADDED) return "#183522"; if (kind == XD_DIFF_LINE_REMOVED) diff --git a/tests/test-unified-diff.c b/tests/test-unified-diff.c index a961e713..986bdcee 100644 --- a/tests/test-unified-diff.c +++ b/tests/test-unified-diff.c @@ -159,6 +159,7 @@ test_reports_row_kinds_without_backgrounds (void) /* An added line with no text of its own still colours its whole row. */ g_assert_cmpint (g_array_index (kinds, guint8, 5), ==, XD_DIFF_LINE_ADDED); + g_assert_cmpstr (xd_diff_line_background (XD_DIFF_LINE_FILE), ==, "#000000"); g_assert_cmpstr (xd_diff_line_background (XD_DIFF_LINE_ADDED), ==, "#183522"); g_assert_cmpstr (xd_diff_line_background (XD_DIFF_LINE_REMOVED), ==, "#3a1d1b"); g_assert_null (xd_diff_line_background (XD_DIFF_LINE_CONTEXT));