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

Raw strings fail if the last line of the sting includes a comment. #632

Open
1 task done
a-stewart opened this issue Apr 17, 2023 · 1 comment
Open
1 task done
Labels

Comments

@a-stewart
Copy link
Contributor

Checklist

  • This problem exists even with the setting "C_Cpp.enhancedColorization": "Disabled"

The code with a problem is:

R"sql(SELECT * FROM foo  -- comment)sql";

It looks like (Default Light+):

image

It should look like:

The comment should end at the end of the string.

image

@jeff-hykin
Copy link
Owner

jeff-hykin commented Apr 17, 2023

This is going to be hard to fix in a generic way.

When the string starts it completely hands control over to the SQL highlighter. And then the SQL highlighter says "everything after the -- is a comment" before giving control back to the C++ highlighter. @ matter123 and I made a tool to help with this called "textmate-bailout", which is where we download a grammar (in this case the SQL grammar), then use the tool to inject code into every single pattern of the grammar (like the comment pattern) so that, instead of their original parsing, those patterns will "bailout" and immediately halt they see something like ".

Its as hacky as it sounds, and we would have to bundle an entire modified SQL grammar inside of the C++ grammar, but its possible. I probably won't be working on that anytime soon though

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

No branches or pull requests

2 participants