Thom1729 / Sublime-JS-Custom

Customizable JavaScript syntax highlighting for Sublime Text.
MIT License
137 stars 9 forks source link

Highlighting breaks on standard JS with flow_types: true #131

Closed mischnic closed 3 years ago

mischnic commented 3 years ago

Sublime Text build number

4121

Example Code

$bar$export$2e2bcd8739ae039({
    displayable: function () {
        return (
            -0.5 <= this.r &&
            this.r < 255.5 &&
            -0.5 <= this.g &&
            this.g < 255.5 &&
            -0.5 <= this.b &&
            this.b < 255.5 &&
            0 <= this.opacity &&
            this.opacity <= 1
        );
    },
    toString: $foo$var$rgb_formatRgb,
});
function $foo$var$rgb_formatHex() {
    return (
        "#" + $foo$var$hex(this.r) + $foo$var$hex(this.g) + $foo$var$hex(this.b)
    );
}

JS Custom Preferences

{
    "configurations": {
        "Default": {}
    },
    "defaults": {
        "file_extensions": ["js", "jsx"],
        "flow_types": true,
        "jsx": true
    }
}

Configuration name

JS Custom - Default

Description

The highlighting breaks in the middle of the file (note that there is no JSX or Flow syntax in this case):

Bildschirmfoto 2021-11-10 um 10 09 25

Everything works correctly when setting "flow_types": false.

Thom1729 commented 3 years ago

Should be fixed in 4.2.2.

The fix is a bit of a hack, but it should work in most practical cases. https://github.com/sublimehq/sublime_text/issues/5003 would open the door for a proper solution.

mischnic commented 3 years ago

Can confirm, thank you!