Bug 495823

Summary: Ruby syntax highlighting wrong for %-string in array, raise with class in module and symbol in method call for instance variable
Product: [Frameworks and Libraries] frameworks-syntax-highlighting Reporter: Mykola Krachkovsky <w01dnick>
Component: syntaxAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: walter.von.entferndt
Priority: NOR    
Version First Reported In: 6.7.0   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Ruby broken highlight cases

Description Mykola Krachkovsky 2024-11-05 09:01:36 UTC
Created attachment 175539 [details]
Ruby broken highlight cases

SUMMARY

After this commit:
https://invent.kde.org/frameworks/syntax-highlighting/-/commit/994c8cc92598a9dac20aa99a89a75b50e21ae3f0

I've found several cases of wrongly highlighted elements. It was one commit, so I've made them one bug report (I could split them if needed).
Rolling back to previous commit `91f60020045733ca55f4ea9290f0862874f3cd16` fixes these problems.

STEPS TO REPRODUCE
1. Open Ruby file, e.g. test.rb
2. Add following code:
```
# Error 1. wrong %-string in array highlighting
string_in_array = [%(#{x} test)]

# Error 2. wrong 1st symbol highlighting in method call for instance variable
data = @hash.slice :key_one, :key_two

# Error 3. wrong class in module highlighting after raise
raise Module::Class
```

Interpolation in first case is not needed, just to emphasize the problem, that its content is highlighted as code, not string, and # interpreted as comment start.
Also I've added attachment (same code, just as separate file).

OBSERVED RESULT

Error 1. %-string is not interpreted as string literal.
Error 2. :key_one is not highlighted as symbol
Error 3. Class is highlighted as symbol :Class

EXPECTED RESULT

Correct highlighting :), similar to previous beviour.

SOFTWARE/OS VERSIONS
Operating System: openSUSE Tumbleweed 20241103
KDE Plasma Version: 6.2.2
KDE Frameworks Version: 6.7.0
Qt Version: 6.8.0
Kernel Version: 6.11.5-2-default (64-bit)
Graphics Platform: Wayland
Processors: 24 × Intel® Core™ i7-14650HX
Memory: 31.1 ГіБ of RAM
Graphics Processor: Mesa Intel® Graphics
Comment 1 Bug Janitor Service 2025-05-21 00:18:11 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/syntax-highlighting/-/merge_requests/703
Comment 2 Christoph Cullmann 2025-05-24 16:23:26 UTC
Git commit 82049fcfebdcc9e560149ff2cbe54448b3b284ea by Christoph Cullmann, on behalf of Jonathan Poelen.
Committed on 24/05/2025 at 16:19.
Pushed by cullmann into branch 'master'.

Ruby: fix %-string and regex in array

```rb
a = [/regex/]
a = [%(str)]
 #   ^ not an operator
```
Related: bug 495349

M  +2    -0    autotests/folding/highlight.rb.fold
M  +2    -0    autotests/html/highlight.rb.dark.html
M  +2    -0    autotests/html/highlight.rb.html
M  +2    -0    autotests/input/highlight.rb
M  +2    -0    autotests/reference/highlight.rb.ref
M  +3    -2    data/syntax/ruby.xml

https://invent.kde.org/frameworks/syntax-highlighting/-/commit/82049fcfebdcc9e560149ff2cbe54448b3b284ea
Comment 3 Christoph Cullmann 2025-05-24 16:23:28 UTC
Git commit 841bfb53e2f8356da5ebd73b71bbb51fe12a0e98 by Christoph Cullmann, on behalf of Jonathan Poelen.
Committed on 24/05/2025 at 16:19.
Pushed by cullmann into branch 'master'.

Ruby: fix operator after method call (expected unary operator or expression)

```rb
foo.bar     /regex/
"abc".match /regex/
 #          ^ not an operator

     foo.bar/10
"abc".length/10
 #          ^ operator (not preceded by space)
```

M  +6    -1    autotests/folding/highlight.rb.fold
M  +6    -1    autotests/html/highlight.rb.dark.html
M  +6    -1    autotests/html/highlight.rb.html
M  +6    -1    autotests/input/highlight.rb
M  +6    -1    autotests/reference/highlight.rb.ref
M  +26   -2    data/syntax/ruby.xml

https://invent.kde.org/frameworks/syntax-highlighting/-/commit/841bfb53e2f8356da5ebd73b71bbb51fe12a0e98
Comment 4 Christoph Cullmann 2025-05-24 16:23:36 UTC
Git commit 59a2eb1082a62f00c0b3898c6d28c464a16efbe3 by Christoph Cullmann, on behalf of Jonathan Poelen.
Committed on 24/05/2025 at 16:19.
Pushed by cullmann into branch 'master'.

Ruby: fix sub class after keyword / function

```rb
raise Module::Class
 #           ^ not a symbol, but
 #          ~~                   Operator
 #            ~~~~~              Constant
```

M  +2    -0    autotests/folding/highlight.rb.fold
M  +2    -0    autotests/html/highlight.rb.dark.html
M  +2    -0    autotests/html/highlight.rb.html
M  +2    -0    autotests/input/highlight.rb
M  +2    -0    autotests/reference/highlight.rb.ref
M  +18   -8    data/syntax/ruby.xml

https://invent.kde.org/frameworks/syntax-highlighting/-/commit/59a2eb1082a62f00c0b3898c6d28c464a16efbe3