Bug 380229

Summary: syntax highlighting for zsh is broken with a mathematical expression in a substring expression
Product: [Frameworks and Libraries] frameworks-syntax-highlighting Reporter: Jonathan Poelen <jonathan.poelen>
Component: syntaxAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: 5.31.0   
Target Milestone: ---   
Platform: Kubuntu   
OS: Linux   
Latest Commit: Version Fixed/Implemented In: 5.37
Sentry Crash Report:

Description Jonathan Poelen 2017-05-26 15:42:13 UTC
In the following zsh expression:

${str:$((${#a[1]}+1))}

The syntax highlighting is broken from '+' to the end of the document.
Comment 1 Jonathan Poelen 2017-06-03 00:22:01 UTC
I suggest replacing

<RegExpr attribute="Variable" context="VarBrace" String="\$\{&varname;" />

with

<RegExpr attribute="Variable" context="VarBrace" String="\$\{#?&varname;" />


Implemented here:

https://github.com/jonathanpoelen/syntax-highlighting/commit/f08aa02684017668738c8e8da7e64aef6100a5b5
Comment 2 Dominik Haumann 2017-07-21 17:56:36 UTC
Git commit 8947f5f06611503f802b1a5a285bf33b12ea02a4 by Dominik Haumann.
Committed on 21/07/2017 at 17:56.
Pushed by dhaumann into branch 'master'.

zsh highlighting: Fix math expression in a substring expression

Thanks to Jonathan Poelen for the initial patch.
In addition, we now also have a small unit test,
taken from http://zshwiki.org/home/examples/hardstatus

FIXED-IN: 5.37

A  +66   -0    autotests/folding/test.zsh.fold
A  +73   -0    autotests/html/test.zsh.html
A  +66   -0    autotests/input/test.zsh
A  +66   -0    autotests/reference/test.zsh.ref
M  +2    -2    data/syntax/zsh.xml

https://commits.kde.org/syntax-highlighting/8947f5f06611503f802b1a5a285bf33b12ea02a4