Diff parser glitches for deleted lines starting with "--"

25 views
Skip to first unread message

Sven Strickroth

unread,
Jan 20, 2017, 4:29:45 PM1/20/17
to scintilla...@googlegroups.com
Hi,

the diff lexer doesn't correctly parse/colorize deleted lines starting
with "--".

There are two cases, whereas I can provide a fix for the first one.

A deleted line "-->" is parsed as HEADER (the attached patch
"Correctly-color-code-deleted-lines-starting-with" fixes this).

When you open example.patch you can see, that a deleted line which only
contains "--" is also colored wrongly, however, the fix is not that easy
and requires context (i.e., we already parsed the header and are in a
hunk context). I'm not sure how to quell this w/o breaking stuff and,
thus, I haven't worked on a patch. - Here unittests with a set of
example files and the the expected parsing would help a lot.

--
Best regards,
Sven Strickroth
PGP key id F5A9D4C4 @ any key-server
Correctly-color-code-deleted-lines-starting-with.patch
example.patch

Neil Hodgson

unread,
Jan 21, 2017, 12:39:57 AM1/21/17
to scintilla...@googlegroups.com
Sven Strickroth:

> the diff lexer doesn't correctly parse/colorize deleted lines starting
> with "--“.

There is a related bug at
https://sourceforge.net/p/scintilla/bugs/1823/

> There are two cases, whereas I can provide a fix for the first one.
>
> A deleted line "-->" is parsed as HEADER (the attached patch
> "Correctly-color-code-deleted-lines-starting-with" fixes this).

The patch seems reasonable.

> When you open example.patch you can see, that a deleted line which only
> contains "--" is also colored wrongly, however, the fix is not that easy
> and requires context (i.e., we already parsed the header and are in a
> hunk context). I'm not sure how to quell this w/o breaking stuff and,
> thus, I haven't worked on a patch. - Here unittests with a set of
> example files and the the expected parsing would help a lot.

Its quite difficult as patch formats overlap and they are generated by different programs and may be processed in various ways such as being copied and pasted from terminal sessions or passed through mailers.

Neil

Neil Hodgson

unread,
Jan 22, 2017, 11:08:07 PM1/22/17
to Scintilla mailing list
Sven Strickroth:

> A deleted line "-->" is parsed as HEADER (the attached patch
> "Correctly-color-code-deleted-lines-starting-with" fixes this).

This patch was committed as
https://sourceforge.net/p/scintilla/code/ci/6b563404748320a12f1425b2320980972b0b0506/

Neil

Reply all
Reply to author
Forward
0 new messages