Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect comment highlighting in YAML #4

Open
texastoland opened this issue Sep 6, 2021 · 2 comments
Open

Incorrect comment highlighting in YAML #4

texastoland opened this issue Sep 6, 2021 · 2 comments

Comments

@texastoland
Copy link

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
Copy link
Author

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
Copy link
Owner

pedro-w commented Feb 25, 2022

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!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants