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

Object field name highlighting breaks when field value contains colon characters #33

Open
risset opened this issue Sep 2, 2024 · 1 comment

Comments

@risset
Copy link

risset commented Sep 2, 2024

For example, in

{
  a: 'b:c'
}

a will not be highlighted.

Adding a space after the colon in the following pattern in jsonnet-font-lock-keywords-1 seems to fix this, but not 100% sure if this would break anything else.

- '("[[:space:]].+:" . font-lock-keyword-face)
+ '("[[:space:]].+: " . font-lock-keyword-face)

Edit: actually since { a:'b:c' } is valid jsonnet, adding a space after the colon in the pattern wouldn't be a great solution :(

@tminor
Copy link
Owner

tminor commented Sep 5, 2024

I can reproduce this with your example, thanks!

It seems the original intent of this regular expression was to match object keys that are also identifiers (i.e. not strings). If that's the case, this is just a bad way to match those cases. Having a look at Jsonnet's specification, it seems this is perhaps an inappropriate use for font-lock-keyword-face which should instead be reserved for real keywords, e.g. assert, else, etc. I was hoping to avoid another regex problem but it seems font-lock-builtin-face is already used for those cases. Like #31, this would be much more nicely solved with tree-sitter, but I assume that's a whole lot of work (at least as involved as converting indentation to SMIE [q.v. #17]).

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