[TxMt] Re: javascript syntax highlighting help
Allan Odgaard
mailinglist at textmate.org
Thu Aug 1 19:02:53 UTC 2019
On 1 Aug 2019, at 19:58, Graham Heath wrote:
> The way I gathered this information was to use "Show scope" ( in a JS
> file with the cursor on the `if`s, this was showing
> "keyword.control.js" for `if ()`, but
> 'punctuation.definition.function-call.begin.js' for `if()`.
>
> Maybe, short of an answer, this helps you figure out the issue? Or
> inspire someone else on the group to help get you an actual answer.
This seems to be a precedence problem.
Line 287 of the grammar has this (includes the rule to match function
calls):
{ include = '#function-call'; },
Then line 305-307 has this rule (to match `if` and other keywords):
{ name = 'keyword.control.js';
match =
'(?<!\.|\$)\b(async|await|break|case|catch|continue|default|do|else|export|finally|for|if|return|switch|throw|try|while|with)\b(?!\$)';
},
The problem is that the rule to match function calls comes first in the
grammar, so when the construct is matched by that line, it never reaches
the keyword rule.
The fix is to move the `keyword.control.js` rule up before the function
call rule.
But the grammar is pretty complex, I didn’t check if there would be
any side effects from this.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macromates.com/textmate/attachments/20190801/e899a0b5/attachment.html>
More information about the TextMate
mailing list