user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: Eric Wong <e@yhbt.net>
Cc: meta@public-inbox.org
Subject: [PATCH] viewdiff: don't increment the reported hunk line number
Date: Sat, 09 May 2020 18:57:46 +0000	[thread overview]
Message-ID: <87pnbdc4wl.fsf@kyleam.com> (raw)
In-Reply-To: <20200509182401.GA20512@dcvr>

Eric Wong writes:

> I'll probably take this patch, soon, got a commit message?

Sure.  Thanks.

-- >8 --
Subject: [PATCH] viewdiff: don't increment the reported hunk line number

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 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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(@@ <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 @@";
-- 
2.26.1


      reply	other threads:[~2020-05-09 18:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-09 17:32 view: why is the diff line number incremented by one? Kyle Meyer
2020-05-09 18:24 ` Eric Wong
2020-05-09 18:57   ` Kyle Meyer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pnbdc4wl.fsf@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=e@yhbt.net \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).