Bug 487932

Summary: Syntax highlighting breaks if last line is blank
Product: [Applications] kate Reporter: aylamz <aylamz>
Component: generalAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED UPSTREAM    
Severity: normal CC: christoph, waqar.17a
Priority: NOR    
Version First Reported In: 24.02.2   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Adding and deleting an empty line to/from the end of a file in Kate to make the bug appear.

Description aylamz 2024-06-02 17:26:18 UTC
Created attachment 170067 [details]
Adding and deleting an empty line to/from the end of a file in Kate to make the bug appear.

SUMMARY
Syntax highlighting breaks if last line is blank or contains only whitespace

STEPS TO REPRODUCE
1.  Open a file that's syntax highlighted
2.  Scroll to the end
3.  Add a new empty line if the last line is not blank

OBSERVED RESULT
Syntax highlighting breaks: functions, etc aren't colored anymore. (See attachment)

EXPECTED RESULT
Syntax highlighting works even if the last line of the file is empty 

SOFTWARE/OS VERSIONS
Linux/KDE Plasma:  Fedora Linux 40
(available in About System)
KDE Plasma Version:  6.0.5
KDE Frameworks Version:  6.2.0
Qt Version:  6.7.1

ADDITIONAL INFORMATION
Also reproduced on the latest git master branch (as of writing this)
Comment 1 Christoph Cullmann 2024-06-20 18:11:45 UTC
Hmm, that is the semantic highlighting info the zig language server sends to us.
Could that be a bug in that? We just send over the content.
Naturally we might handle the response wrong.
Comment 2 aylamz 2024-06-21 06:26:43 UTC
(In reply to Christoph Cullmann from comment #1)
> Hmm, that is the semantic highlighting info the zig language server sends to
> us.
> Could that be a bug in that? We just send over the content.
> Naturally we might handle the response wrong.

Don't know, but I can't reproduce this bug in other text editors such as Helix and VSCodium.
Comment 3 Waqar Ahmed 2024-07-26 17:54:20 UTC
Debugged this a little bit, seems to be a server issue. 

When a range with last line == empty, the server sends over a response which highlights all the comments in the document for some reason??

Filed an issue https://github.com/zigtools/zls/issues/1974
Comment 4 Waqar Ahmed 2024-07-29 07:12:01 UTC
Fixed on the server side, closing.