slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.54k stars 600 forks source link

String with escape in string breaks syntax highlighting in VS Code #6014

Open Enyium opened 2 months ago

Enyium commented 2 months ago

Consider this .slint code:

import { Button } from "std-widgets.slint";

export component AppWindow {
    property <int> value;

    Text {
        text: "\{root.value > 0 ? "\u{2003}" : ""}";
    }

    Button {
        clicked => {
            // ...
        }
    }
}

It works, but is rendered for me in VS Code on Windows 10 in the following broken way:

broken-highlighting

With just the string } instead of the whole escape sequence, it's still broken:

still-broken-highlighting

With only { though, everything is correct:

nonbroken-highlighting

ogoffart commented 2 months ago

Interestingly, the snippet you pasted on github has a similar issue in the github highlighting. So this point out to a bug in the textmate grammar (https://github.com/slint-ui/slint/blob/master/editors/vscode/slint.tmLanguage.json) which is used by both.

hunger commented 2 months ago

This is not fixable within the limits of the textmate grammar :-/ It's basically regular expressions matching line contents.