SublimeText / CoffeeScript

Syntax highlighting and checking, commands, shortcuts, snippets, watched compilation and more.
439 stars 64 forks source link

Anonymous and inline class declaration syntax highlighting broken #222

Closed vgel closed 8 years ago

vgel commented 9 years ago

As seen here:

image

All those class declarations are valid coffeescript, but only the last is highlighted.

Code shown above for reference:

foo = new class extends Bar
    constructor: ->
        # sadness :(

foo = new class Baz extends Bar
    constructor: ->
        # also broken

foo = new (class extends Bar
    constructor: ->
        # parenthesizes alone don't fix it
)

foo = new (class Baz extends Bar
    constructor: ->
        # but naming + parenthesizes do
)
markalfred commented 9 years ago

This should be resolved by the regex here: https://github.com/aponxi/sublime-better-coffeescript/issues/200#issuecomment-67495654 I'll try to open up a PR tonight unless someone else can hit it first :+1:

vgel commented 9 years ago

I pulled in those regexes to my fork and it partially, but not entirely fixes the problem:

image

I'm not sure why, because the regex seems to match. Maybe the new regex is taking precedence?

image

I'll take a look at this more later tonight.

vgel commented 9 years ago

Yeah, that was it. Adding a similar fix to new to not match class makes everything work:

image

Will submit the pull in a bit.

vgel commented 9 years ago

Used http://issue2pr.herokuapp.com to turn this issue into a pull request with the fixes, in case of confusion.

markalfred commented 9 years ago

Very nice, @Rotten194, and +1 for introducing me to issue2pr