Bug 397719 - Alert matching differs from KTextEditor to KSyntaxHighlighting
Summary: Alert matching differs from KTextEditor to KSyntaxHighlighting
Status: RESOLVED FIXED
Alias: None
Product: frameworks-syntax-highlighting
Classification: Frameworks and Libraries
Component: framework (other bugs)
Version First Reported In: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-21 20:01 UTC by Dominik Haumann
Modified: 2018-09-01 08:27 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
Left: KTextEditor, Right:KSyntaxHighlighting (47.72 KB, image/png)
2018-08-21 20:03 UTC, Dominik Haumann
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dominik Haumann 2018-08-21 20:01:26 UTC
See attached screenshot.

Python fragment:




def asdfasdf:
    asdfasdfa
    asdfasdf
    #FIXME ### NOTE
    #NOTE
    #NOTE
def asdfasd
    adf sad
Comment 1 Dominik Haumann 2018-08-21 20:03:34 UTC
Created attachment 114534 [details]
Left: KTextEditor, Right:KSyntaxHighlighting

See the different between left KTextEditor and right KSyntaxHighlighting.
Comment 2 Volker Krause 2018-08-22 07:12:50 UTC
This looks like it's caused by a missing space between the alert keyword and the comment marker. I don't have the old version around to compare, but e.g. "/**TODO" with C++ highlighting also doesn't highlight TODO as alert, so this might be a more generic issue.
Comment 3 Christoph Cullmann 2018-08-22 07:16:38 UTC
/**TODO */

doesn't highlight in C++ pre-syntax-highlighting here, too.

non-doxygen stuff like

/*TODO*/
//TODO

does
Comment 4 Volker Krause 2018-08-22 07:20:52 UTC
The difference might be that the new implementation for the keyword rule also checks if there's a word delimiter before the keyword, not just after it? That's at least if I read the old implementation correctly. If so, that's easy to fix then, just drop that extra check.
Comment 5 Christoph Cullmann 2018-08-22 07:33:37 UTC
Hmm, why does it work without the Doxygen hl, e.g. for normal comments?

I would assume * is a word delimiter and as /*TODO*/ works, that check is ok.
Comment 6 Volker Krause 2018-08-22 07:54:05 UTC
Indeed, * is a delimiter, but # isn't. So this explains the Python difference but nothing related to C++. Presumably we would see the issue with other languages using # as a comment character though, like Bash or Perl.
Comment 7 Dominik Haumann 2018-08-22 16:08:44 UTC
In that case, I am in favor of adding # to the standard delimiters. Or would that be a problem?
Comment 8 Volker Krause 2018-08-22 17:12:48 UTC
Seems reasonable, but I can't estimate the impact of this. Maybe run the unit tests with that and see how much breaks?
Comment 9 Christoph Cullmann 2018-08-22 18:10:50 UTC
The question is: as that doesn't solve the * case, perhaps one should first take a look why that doesn't work. Or is that just a Doxygen hl glitch?
Comment 10 Christoph Cullmann 2018-09-01 08:05:39 UTC
https://phabricator.kde.org/D15196
Comment 11 Christoph Cullmann 2018-09-01 08:27:14 UTC
Git commit 2475bc4dd2ca94eaaaa4ab98a695d89ac200f5c4 by Christoph Cullmann.
Committed on 01/09/2018 at 08:26.
Pushed by cullmann into branch 'master'.

avoid word delimiter check at start of keyword

Summary:
be compatible with old KTextEditor implementation

Test Plan:
added test for python showing the error
works now
only other diff in coffee, looks not wrong, function as keyword

make && make test

Reviewers: vkrause, dhaumann

Reviewed By: vkrause

Subscribers: kwrite-devel, kde-frameworks-devel

Tags: #kate, #frameworks

Differential Revision: https://phabricator.kde.org/D15196

M  +3    -0    autotests/folding/test.py.fold
M  +1    -1    autotests/html/test.coffee.html
M  +3    -0    autotests/html/test.py.html
M  +3    -0    autotests/input/test.py
M  +1    -1    autotests/reference/test.coffee.ref
M  +3    -0    autotests/reference/test.py.ref
M  +0    -3    src/lib/rule.cpp

https://commits.kde.org/syntax-highlighting/2475bc4dd2ca94eaaaa4ab98a695d89ac200f5c4