Bug 464048

Summary: Broken syntax highlight when using constructions like '{}' or "${VAR}" in BASH source code
Product: [Applications] kile Reporter: Vojtěch Zeisek <Vojtech.Zeisek>
Component: editorAssignee: Michel Ludwig <michel.ludwig>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: 2.9.93   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: kile_syntax_1.png
kile_syntax_2.png
kile_syntax_3.png
kile_syntax_4.png
kile_syntax_5.png
kile_syntax_6.png
kile_syntax_7.png

Description Vojtěch Zeisek 2023-01-09 12:56:03 UTC
Created attachment 155133 [details]
kile_syntax_1.png

I'm using LaTeX package minted to show syntax highlight with R or BASH source code. There are certain constructions which completely mess up syntax in whole editor (see further).

I'll describe examples accompanied by screenshots. The discussed TeX source file is at https://github.com/V-Z/course-linux-command-line-bash-scripting-metacentrum/blob/master/presentation/linux_bash_metacentrum_course.tex if needed.

File kile_syntax_1.png

Probably not the best example of syntax problems I found as I show on line 1749 wrong code, the syntax highlight behaves technically probably correctly, but natural human reading would be different. Following examples are really problematic.

Files kile_syntax_2.png and kile_syntax_3.png

I don't see any wrong code on my construction with find ... | parallel... As You use (and as can be easily tested within Kile with the input file), problematic construction is whatever like '{}' causing basically rest of file to be yellow, at least to another such construction. As file kile_syntax_3.png shows changing
find . -name '*.jpg' -print | parallel --bar convert '{}' '{.}.png'
to
find . -name '*.jpg' -print | parallel --bar convert {} {.}.png
(and similarly for other cases) fixes the display issue. In any case, rendering of resulting PDF is correct. So I think this is clear bug of Kile or it's syntax highlight component.

File kile_syntax_4.png

I admit that writing on beginning of line \(ToRemember\) isn't the best idea (should be commented out or so), but what I think is bug of Kile or it's syntax highlight component is fact that it breaks syntax highlight of the \end{bashcode}, \end{frame} and following XeLaTeX code. Of course, if I comment the problematic line with \(ToRemember\) using #, everything is fine. Interestingly, line \Number doesn't cause any problem. Anyway, I think it's a bug that whatever content of bascode minted environment influences following XeLaTeX code.

File kile_syntax_5.png

Partially, Kile works correctly as the 1st slide contains incomplete 'case' construction, but same problem as with previous example, I think whatever inside bashcode minted environment shouldn't influence of highlight of "standard" XeLaTeX code. Of course, if I add 'esac' to the end, this slide will be OK, but the following will again break due to "o)" starting without "case". More generally, I think it can happen often that You need to show some construction on multiple slides, and I think the situation doesn't have good solution now. Good think is that rendering of PDF is correct, so I think it's problem with Kile.

Files kile_syntax_6.png and kile_syntax_7.png

It's similar problem as shown on files kile_syntax_2.png and kile_syntax_3.png. Construction like "${VAR}" completely break syntax highlight in Kile editor. And I think this is a bug.

Interestingly, I hadn't opened this for some time and I don't recall such issues with previous versions (I use openSUSE Tumbleweed, which is rolling-release, thus usually having newest versions of everything). Of course I'd be happy to provide any further cooperation as I'd like to see this fixed.
Comment 1 Vojtěch Zeisek 2023-01-09 12:57:08 UTC
Created attachment 155134 [details]
kile_syntax_2.png
Comment 2 Vojtěch Zeisek 2023-01-09 12:57:26 UTC
Created attachment 155135 [details]
kile_syntax_3.png
Comment 3 Vojtěch Zeisek 2023-01-09 12:57:41 UTC
Created attachment 155136 [details]
kile_syntax_4.png
Comment 4 Vojtěch Zeisek 2023-01-09 12:57:58 UTC
Created attachment 155137 [details]
kile_syntax_5.png
Comment 5 Vojtěch Zeisek 2023-01-09 12:58:15 UTC
Created attachment 155138 [details]
kile_syntax_6.png
Comment 6 Vojtěch Zeisek 2023-01-09 12:58:31 UTC
Created attachment 155139 [details]
kile_syntax_7.png
Comment 7 Bug Janitor Service 2023-09-17 16:10:18 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/syntax-highlighting/-/merge_requests/548
Comment 8 Christoph Cullmann 2023-09-17 22:10:47 UTC
Git commit 49c0cf9e33c9d94f2e98aadf1cc445bb99cd4601 by Christoph Cullmann, on behalf of Jonathan Poelen.
Committed on 18/09/2023 at 00:08.
Pushed by cullmann into branch 'master'.

LaTeX: fix bash code block

This fixes the issue with images 2, 3, 4, 6 and 7

Image 5 can only be fixed by adding a new form of rule that doesn't exist and requires a lot of change in the engine. Image 1 is not particularly a problem.

M  +6    -0    autotests/folding/highlight.tex.fold
M  +6    -0    autotests/html/highlight.tex.dark.html
M  +6    -0    autotests/html/highlight.tex.html
M  +6    -0    autotests/input/highlight.tex
M  +6    -0    autotests/reference/highlight.tex.ref
M  +2    -2    data/syntax/latex.xml

https://invent.kde.org/frameworks/syntax-highlighting/-/commit/49c0cf9e33c9d94f2e98aadf1cc445bb99cd4601