Bug 465304

Summary: syntax highlighting for QML is broken when file starts with shebang
Product: [Frameworks and Libraries] frameworks-syntax-highlighting Reporter: kdebugs
Component: syntaxAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: walter.von.entferndt
Priority: NOR    
Version First Reported In: 5.98.0   
Target Milestone: ---   
Platform: Other   
OS: Other   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description kdebugs 2023-02-05 04:20:30 UTC
SUMMARY
Syntax highlighting for QML files is broken when the file includes shebang line.

STEPS TO REPRODUCE
1. Open kate.
2. Make and save a QML file, e.g. "hello.qml":
import QtQuick 2
Rectangle {
    width: 200
    height: 100
    Text {
        text: "Hello, World!"
    }
}

3. Add a shebang line at the beginning of the file, e.g.
#!/usr/bin/env qml

OBSERVED RESULT
When you add the shebang, everything but the first two characters (or until a /* multi-line comment */) turns orange (or green, in eariler versions.)

EXPECTED RESULT
Shebang should not break highlighting.

SOFTWARE/OS VERSIONS
Kubuntu 22.10
KDE Plasma Version: 5.25.5
KDE Frameworks Version: 5.98.0
Qt Version: 5.15.6
Kate 22.08.2

ADDITIONAL INFORMATION
A commit related to Bug 325805 apparently fixed this for JavaScript in 2014.  That commit also involved a minor change to qml.xml, however I don't think it ever worked in QML.  Copying the lines related to shebang from javascript.xml into qml.xml seems to make it correctly recognize the shebang line, except that it doesn't color it like a comment, and I don't know enough about this syntax highlighting system to know how to fix that.
Comment 1 Bug Janitor Service 2023-02-05 16:40:00 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/syntax-highlighting/-/merge_requests/446
Comment 2 Christoph Cullmann 2023-02-06 22:20:49 UTC
Git commit 8514122344088507ff18639ffbed2a947202a5b9 by Christoph Cullmann, on behalf of Jonathan Poelen.
Committed on 06/02/2023 at 22:20.
Pushed by cullmann into branch 'master'.

QML: add shebang

M  +4    -4    data/syntax/latex.xml
M  +2    -2    data/syntax/markdown.xml
M  +10   -1    data/syntax/qml.xml

https://invent.kde.org/frameworks/syntax-highlighting/commit/8514122344088507ff18639ffbed2a947202a5b9