]> Sergey Matveev's repositories - public-inbox.git/commitdiff
viewdiff: don't increment the reported hunk line number
authorKyle Meyer <kyle@kyleam.com>
Sat, 9 May 2020 18:57:46 +0000 (18:57 +0000)
committerEric Wong <e@yhbt.net>
Sat, 9 May 2020 19:32:11 +0000 (19:32 +0000)
For a diff hunk starting at line N, diff_hunk() constructs the link
with "#n(N + 1)".  This sends the viewer one line below the first
context line.  Although this is minor and may not even be noticed,
there's not an obvious reason to increment the line number, so switch
to using the reported value as is.

lib/PublicInbox/ViewDiff.pm

index 6fe9a0d7610e5a345ede4c74abd362514502ce61..536bb9e3c99e458e486e96f0abdb2fa9eca83637 100644 (file)
@@ -50,12 +50,12 @@ sub diff_hunk ($$$$) {
 
        if (defined($spfx) && defined($oid_a) && defined($oid_b)) {
                my ($n) = ($ca =~ /^-([0-9]+)/);
-               $n = defined($n) ? do { ++$n; "#n$n" } : '';
+               $n = defined($n) ? "#n$n" : '';
 
                $$dst .= qq(@@ <a\nhref="$spfx$oid_a/s/$dctx->{Q}$n">$ca</a>);
 
                ($n) = ($cb =~ /^\+([0-9]+)/);
-               $n = defined($n) ? do { ++$n; "#n$n" } : '';
+               $n = defined($n) ? "#n$n" : '';
                $$dst .= qq( <a\nhref="$spfx$oid_b/s/$dctx->{Q}$n">$cb</a> @@);
        } else {
                $$dst .= "@@ $ca $cb @@";