From ad5bb37770185bcff040e4821263ce7902ca703c Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 31 Oct 2026 13:34:51 -0700 Subject: Hand the side by side view its file pair --- source/ui-ssdiff.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'source/ui-ssdiff.c') diff --git a/source/ui-ssdiff.c b/source/ui-ssdiff.c index afa25ea..75f8185 100644 --- a/source/ui-ssdiff.c +++ b/source/ui-ssdiff.c @@ -21,6 +21,8 @@ struct deferred_line { struct deferred_line *next; }; +// The pair being rendered, whose two sides the line number links lead into. +static struct diff_filepair *current_filepair; static int current_old_line, current_new_line; static int **lcs_table; static struct deferred_line *deferred_old, *deferred_old_last; @@ -196,7 +198,7 @@ static void print_row(const char *class, int old_line_no, char *old_line, lcs = longest_common_subsequence(old_line, new_line); html("\n"); if (old_line_no > 0) { - print_lineno_cell(cgit_get_current_old_file(), old_rev_oid, old_line_no); + print_lineno_cell(current_filepair->one, old_rev_oid, old_line_no); htmlf("", class); } else if (old_line) { htmlf("", class); @@ -212,7 +214,7 @@ static void print_row(const char *class, int old_line_no, char *old_line, html("\n"); if (new_line_no > 0) { - print_lineno_cell(cgit_get_current_new_file(), new_rev_oid, new_line_no); + print_lineno_cell(current_filepair->two, new_rev_oid, new_line_no); htmlf("", class); } else if (new_line) { htmlf("", class); @@ -401,12 +403,13 @@ void cgit_ssdiff_line_cb(char *line, int len) line[len - 1] = terminator; } -void cgit_ssdiff_header_begin(const char *path) +void cgit_ssdiff_header_begin(struct diff_filepair *pair) { + current_filepair = pair; current_old_line = -1; current_new_line = -1; html("\n"); html("\n"); html(""); -- cgit