Created attachment 119059 [details] Unfortunate fate for an otherwise fine line - invaded by a greedy macro. Hello, CONSIDER THE FOLLOWING C CODE (notice the backslash at the end of the first line): #define hello "hello" \ int main() { puts(hello); return 0; } OBSERVED RESULT The line: int main() { puts(hello); return 0; } Appears in non-bold green with the default highlighting settings. EXPECTED RESULT Said line should be highlighted (everything in black except "int" in blue and 0 in yellow, and "return" in bold with the default highlighting settings). ADDITIONAL INFORMATION $ gcc -ansi test.c -o t; ./t hello if any character (space, letter or anything) is added to line 2, the highlighting is done correctly. Also, KDevelop seems unaffected by this issue. SOFTWARE/OS VERSIONS - Kate 18.08.0, KDE Frameworks 5.54.0, Qt 5.11.3 on Debian GNU/Linux testing - Kate 19.07.70, KDE Frameworks 5.57.0, Qt 5.12.0 from the latest KDE Neon Docker image WHY WOULD YOU END A MACRO WITH A BACKSLASH? I also indent code using 7 spaces and one tab in the middle of them and ban people who mess this up from my projects.
This isn't a bug of the C or C++ highlighter, but it's a bug of the "LineContinue" rule. If you write the following using C or JavaScript syntax highlighting: "string \ other text " "other text" is also highlighted as a string, since the "LineContinue" rule (character "\") skips the empty lines. The expected result is that LineContinue ends when an empty line is detected. This bug exists in KF5.56.0, but doesn't exist in KF5.48.0
I changed this bug to -> framework-syntax-highlighting (component: framework), version 5.56.0 Proposed patch: https://phabricator.kde.org/D20148
Git commit b518dcc6486a4dc23785c2d53ae339a9d327e546 by Nibaldo González. Committed on 02/04/2019 at 05:21. Pushed by ngonzalez into branch 'master'. Allow line end context switches in empty lines Summary: ### Bug: Don't skip empty lines after matching a LineContinue rule: When you write an empty line after a line continuation character, the empty lines are ignored. This generates an incorrect highlight, since it includes within the context multiple lines after a line continuation character, when the respective context has `lineEndContext="#pop"`. {F6739814} The problem is caused because the `lineEndContext` attribute doesn't work in empty lines. Now `lineEndContext` works in empty lines, but only if `lineEmptyContext` is #stay. Reviewers: #framework_syntax_highlighting, cullmann, dhaumann, vkrause Reviewed By: #framework_syntax_highlighting, cullmann Subscribers: kwrite-devel, kde-frameworks-devel Tags: #kate, #frameworks Differential Revision: https://phabricator.kde.org/D20148 M +12 -0 autotests/folding/test.c.fold M +12 -0 autotests/html/test.c.html M +12 -0 autotests/input/test.c M +12 -0 autotests/reference/test.c.ref M +17 -2 src/lib/abstracthighlighter.cpp https://commits.kde.org/syntax-highlighting/b518dcc6486a4dc23785c2d53ae339a9d327e546