From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 800B71F8C1; Sat, 9 May 2020 18:24:01 +0000 (UTC) Date: Sat, 9 May 2020 18:24:01 +0000 From: Eric Wong To: Kyle Meyer Cc: meta@public-inbox.org Subject: Re: view: why is the diff line number incremented by one? Message-ID: <20200509182401.GA20512@dcvr> References: <87tv0pc8vg.fsf@kyleam.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <87tv0pc8vg.fsf@kyleam.com> List-Id: Kyle Meyer wrote: > Diff links position the line one beyond what I expect. Here's a hunk at > : > The link at "-71,11" is > . > When I follow it, I'm taken to line 72, one line below the first context > line above. I haven't been able to come up with a reason why +1 would > be preferable here, and I didn't spot any explanation when looking > around the code. It looks like it'd just be a matter of making the > two-line change below, but perhaps that causes breakage that I didn't > notice with my light testing. Good question, it's been that way since the beginning... It might have been due to the "0" for new files and line numbers counting starting at "1". But hunks aren't hyperlinks for new files, since the blob OID already is. > diff --git a/lib/PublicInbox/ViewDiff.pm b/lib/PublicInbox/ViewDiff.pm > index 6fe9a0d7..536bb9e3 100644 > --- a/lib/PublicInbox/ViewDiff.pm > +++ b/lib/PublicInbox/ViewDiff.pm > @@ -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(@@ {Q}$n">$ca); > > ($n) = ($cb =~ /^\+([0-9]+)/); > - $n = defined($n) ? do { ++$n; "#n$n" } : ''; > + $n = defined($n) ? "#n$n" : ''; > $$dst .= qq( {Q}$n">$cb @@); > } else { > $$dst .= "@@ $ca $cb @@"; I'll probably take this patch, soon, got a commit message? Given the massive change Eml is, 1.5.0 will probably be released, soon.