Skip to content
Merged
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
4 changes: 3 additions & 1 deletion src/util/unified-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -288,7 +290,7 @@ append_file_markup (MarkupBuilder *builder,
start_markup_row (builder, line->kind);
g_string_append_printf (
builder->text,
"<span weight=\"bold\">%s</span>"
"<span foreground=\"#ffbe6f\" weight=\"bold\">%s</span>"
" <span foreground=\"#57e389\">+%u</span>"
" <span foreground=\"#f66151\">−%u</span>",
path, additions, deletions);
Expand Down
3 changes: 3 additions & 0 deletions tests/test-unified-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <value>"));
g_assert_nonnull (strstr (plain, "Showing first 3 of 5 rows"));
g_assert_nonnull (strstr (
markup, "foreground=\"#ffbe6f\" weight=\"bold\">src/a.c</span>"));
g_assert_nonnull (strstr (markup, "foreground=\"#f66151\""));
}

Expand Down Expand Up @@ -157,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));
Expand Down
Loading