pedro-w / vscode-tmlanguage

Syntax highlighting for TextMate/SublimeText language definitions
MIT License
18 stars 4 forks source link

Incorrect comment highlighting in YAML #4

Open texastoland opened 2 years ago

texastoland commented 2 years ago

I assume the rules are just in the wrong order in the patterns array.

patterns:
- include: #should highlight as comment
-
  match: |
    (?x)
    (
      this|that # should highlight as comment
    )
texastoland commented 2 years ago

I fixed the first case in my fork but the second looks too complicated.

YAML first highlights comments then injects the regex grammar. end matches don't follow the rules about not overwriting previously consumed matches with new scopes. So the regex grammar overwrites the comment tokens while matching paren pairs.

The regex grammar could highlight comments itself but it might be tricky to restrict to multiline expressions. The YAML grammar can't use the end hack because the beginning # is already consumed by the regex grammar.

pedro-w commented 2 years ago

Just checking - currently the first comment is formatted and the second is not. But is YAML syntax highlighting our job? (I've just updated the extension with @SNDST00M fix to change the extension to .tmLanguage.yml, and I think VSCode does it now) Screenshot 2022-02-25 at 17 32 59

Anyway, with the official RedHat YAML extension loaded (and not ours) the second comment is not highlighted, and neither is it with Pygments (See here) So maybe this problem is a hard one (or maybe that comment shouldn't highlight, I've never used YAML for anything!)