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

Syntax highlighting incorrectly highlights quoted string in command #3

Open
fmoo opened this issue Jan 7, 2022 · 1 comment
Open

Comments

@fmoo
Copy link

fmoo commented Jan 7, 2022

Repro case:

title: InitGlobal
---
<<TODO "Initialize anything">>
===

produces the following:
image

This is on version 2.0, released on 12/18

@fmoo fmoo changed the title Syntax highlighting incorrectly highlights last character of quoted string in command Syntax highlighting incorrectly highlights quoted string in command Jan 7, 2022
@McJones
Copy link
Contributor

McJones commented Apr 28, 2022

I had a hunch as to this and it turned out to be correct. Not sure what the best fix should be at this stage but writing this down so I don't forget the cause.

The issue is in SemanticTokenVisitor.cs SplitCommandText function in the LSP.
That correctly identifies in the above example there are two tokens TODO and Initialize anything but because that splitting code is dropping the the "'s at either end (because its mostly the correct thing to do) the range of the token is off by two.
This is where the trick is, by default the extension will use a basic syntax highlighter that will see "Initialize anything" as a String later the LSP runs and goes "yeah nah that isn't a string its a parameter" which is correct but because the LSPs tokens are two shorter the last two characters are still using their initial "I am a string" settings they got from the first syntax highlight pass.

I suppose can just add the "'s back in but I would have to check if that causes issues with other parts of the LSP that check the validity of commands.

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