user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* syntax highlighting bug with lines containing '>'
@ 2019-02-04 10:54 SZEDER Gábor
  2019-02-04 11:49 ` [PATCH] viewdiff: group path match to not be confused by "/dev/null" Eric Wong
  0 siblings, 1 reply; 2+ messages in thread
From: SZEDER Gábor @ 2019-02-04 10:54 UTC (permalink / raw)
  To: meta

Hi,

First of all, thanks you very much for adding syntax highlighting for
patch emails, it's fantastic!

However, I noticed that a patch I recently sent to the Git mailing
list got bogus syntax highlighting, as the added line is colored as
removed:

  https://public-inbox.org/git/20190202163421.19686-1-szeder.dev@gmail.com/  

Perhaps the '>' shell redirection operator causes troubles?  I clicked
around in the list archives, and sure enough found other occurrance of
this bug, that also seems to suggest that a '>' might be problematic
only when it's on the first added line:

  https://public-inbox.org/git/20190203210027.13272-1-svenvh@gmail.com/

Dunno, I have no idea how any of this works, so I stop spinning
theories about what could possibly be the cause.


Gábor


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] viewdiff: group path match to not be confused by "/dev/null"
  2019-02-04 10:54 syntax highlighting bug with lines containing '>' SZEDER Gábor
@ 2019-02-04 11:49 ` Eric Wong
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2019-02-04 11:49 UTC (permalink / raw)
  To: SZEDER Gábor; +Cc: meta

SZEDER Gábor <szeder.dev@gmail.com> wrote:
> Hi,
> 
> First of all, thanks you very much for adding syntax highlighting for
> patch emails, it's fantastic!

You're welcome, but it's clearly a work-in-progress :)

> However, I noticed that a patch I recently sent to the Git mailing
> list got bogus syntax highlighting, as the added line is colored as
> removed:
> 
>   https://public-inbox.org/git/20190202163421.19686-1-szeder.dev@gmail.com/  
> 
> Perhaps the '>' shell redirection operator causes troubles?  I clicked
> around in the list archives, and sure enough found other occurrance of
> this bug, that also seems to suggest that a '>' might be problematic
> only when it's on the first added line:

Not the '>', it was actually "/dev/null" :x

The following seems to work:

---------8<--------
Subject: [PATCH] viewdiff: group path match to not be confused by "/dev/null"
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Leaving out parentheses caused transitions to state="del" or
state="add" to be misidentified.

cf. https://public-inbox.org/meta/20190204105454.GG10587@szeder.dev/

Reported-by: SZEDER Gábor <szeder.dev@gmail.com>
---
 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 c818203..a773e38 100644
--- a/lib/PublicInbox/ViewDiff.pm
+++ b/lib/PublicInbox/ViewDiff.pm
@@ -190,8 +190,8 @@ sub flush_diff ($$$) {
 			$$dst .= '</span>';
 			$state = DSTATE_CTX;
 			$$dst .= to_html($linkify, $s);
-		} elsif ($s =~ m!^--- $PATH_A! ||
-		         $s =~ m!^\+{3} $PATH_B!)  {
+		} elsif ($s =~ m!^--- (?:$PATH_A)! ||
+		         $s =~ m!^\+{3} (?:$PATH_B)!)  {
 			# color only (no oid link) if missing dctx->{oid_*}
 			$state <= DSTATE_STAT and
 				to_state($dst, $state, DSTATE_HEAD);
-- 
EW

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-02-04 11:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-04 10:54 syntax highlighting bug with lines containing '>' SZEDER Gábor
2019-02-04 11:49 ` [PATCH] viewdiff: group path match to not be confused by "/dev/null" Eric Wong

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).