genoma / language-pug

A Pug (was Jade) syntax highlighting for Atom, derived from https://github.com/davidrios/jade-tmbundle
MIT License
26 stars 8 forks source link

Broken attribute highlighting when using tag name interpolation #27

Open nkovacs opened 7 years ago

nkovacs commented 7 years ago
- var tag='a'
// Broken
#{tag}(
    @click="doSomething", 
    :href="url",
)
// Broken
#{tag}(
    click="doSomething", 
    href="url",
)
// These work fine
a(
    @click="doSomething",
    :href="url",
)
a(
    click="doSomething",
    href="url",
)

screenshot from 2017-04-27 08-47-42

nkovacs commented 7 years ago

Ok, so the issue seems to be with the interpolation subpattern having the same name: https://github.com/genoma/language-pug/blob/f1f1610222a9f14f0a95fdffcd579a6e4cb64b42/grammars/pug.cson#L1096

It looks like this prevents the tag_name pattern from ending correctly, because if I log the cursor scope at ( (with the cursor in front of it), it still says "source.script.jade entity.name.tag.pug", whereas without the interpolation, it says "constant.name.attribute.tag.pug".

Renaming it to "source.script.jade entity.name.tag.pug.interpolated" fixes the highlighting for the attributes (the tag name ends correctly at } now), but the highlighting of the interpolation doesn't work correctly (it doesn't seem to work that well anywhere else either).