[TxMt] Re: javascript syntax highlighting help

Robert J. Carr rjcarr at gmail.com
Wed Aug 28 22:04:45 UTC 2019


Hi Allan-

Sorry for the late reply, but changing the order did seem to fix the
problem, but like you said I don't know what the side effects will be.
I'll keep the original grammar as a backup in case something goes wrong,
but thanks for taking the time to look into this.

Robert


On Thu, Aug 1, 2019 at 12:03 PM Allan Odgaard <mailinglist at textmate.org>
wrote:

> 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.
>
> _______________________________________________
> textmate mailing list
> textmate at lists.macromates.com
> https://lists.macromates.com/listinfo/textmate
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macromates.com/textmate/attachments/20190828/9e0f2e73/attachment.html>


More information about the TextMate mailing list