From 886a798235f08bb706bf5350368840fce6e63b41 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 31 Oct 2026 13:36:45 -0700 Subject: Write both halves of a side by side row one way --- source/ui-ssdiff.c | 57 ++++++++++++++++++++++++------------------------------ 1 file changed, 25 insertions(+), 32 deletions(-) (limited to 'source') diff --git a/source/ui-ssdiff.c b/source/ui-ssdiff.c index 61573d9..4bddb9d 100644 --- a/source/ui-ssdiff.c +++ b/source/ui-ssdiff.c @@ -184,6 +184,27 @@ static void print_lineno_cell(struct diff_filespec *file, const struct object_id strbuf_release(&path); } +/* + * mark is the class for the characters this side of the row does not share + * with the other. + */ +static void print_side(const char *class, struct diff_filespec *file, const struct object_id *rev, + int line_no, const char *line, const char *lcs, const char *mark) +{ + if (line_no > 0) + print_lineno_cell(file, rev, line_no); + else + html(""); + htmlf("", class, line ? "" : "-dark"); + if (line) { + if (lcs) + print_line_with_lcs(mark, line, lcs); + else + html_txt(line); + } + html(""); +} + static void print_row(const char *class, int old_line_no, char *old_line, int new_line_no, char *new_line, int highlight_chars) { @@ -197,38 +218,10 @@ static void print_row(const char *class, int old_line_no, char *old_line, if (highlight_chars && old_line && new_line) lcs = longest_common_subsequence(old_line, new_line); html("\n"); - if (old_line_no > 0) { - print_lineno_cell(current_filepair->one, old_rev_oid, old_line_no); - htmlf("", class); - } else if (old_line) { - htmlf("", class); - } else { - htmlf("", class); - } - if (old_line) { - if (lcs) - print_line_with_lcs("del", old_line, lcs); - else - html_txt(old_line); - } - - html("\n"); - if (new_line_no > 0) { - print_lineno_cell(current_filepair->two, new_rev_oid, new_line_no); - htmlf("", class); - } else if (new_line) { - htmlf("", class); - } else { - htmlf("", class); - } - if (new_line) { - if (lcs) - print_line_with_lcs("add", new_line, lcs); - else - html_txt(new_line); - } - - html("\n"); + print_side(class, current_filepair->one, old_rev_oid, old_line_no, old_line, lcs, "del"); + html("\n"); + print_side(class, current_filepair->two, new_rev_oid, new_line_no, new_line, lcs, "add"); + html("\n"); free(lcs); free(new_line); free(old_line); -- cgit 2.11.1