better-cpp-syntax
better-cpp-syntax copied to clipboard
A raw string literal inside a struct/class definition breaks the highlighting
Checklist
- [ ] This problem exists even with the setting
"C_Cpp.enhancedColorization": "Disabled"→ Not sure, see below - [ ] This bug exists for C
- [x] This bug exists for C++
- [ ] This bug exists for Objective-C
- [ ] This bug exists for Objective-C++
The issue persists even after I add "C_Cpp.enhancedColorization": "Disabled" to settings.json and restart VS Code, but VS Code says that C_Cpp.enhancedColorization is an unknown configuration setting, so I am not sure if I am adding the setting correctly. I am using VS Code 1.51.1 on Mac.
The code with a problem is:
struct S {
int x =
f(R"(some raw string literal)");
int y = 100;
const char* z = "hello";
};
It looks like:

Color Theme: Default Light+
It should look like:
The raw string literal should be colored like a string literal, and everything after that should not be colored like a string literal.
This seems to effect any string literals inside parentheses, it seems to be fixable by adding #string_context before #parameter in the function_parameter_context within the json file.

Just a follow up on this, it looks like we can still reach an error state even with the fix submitted last year.
Result after existing fix:

But we can break this by simply adding whitespace before the start of the raw string:
struct S {
int x =
f( R"(some raw string literal)");
int y = 100;
const char* z = "hello";
};

Or adding another nested call:
struct S {
int x =
f(g(R"(some raw string literal)"));
int y = 100;
const char* z = "hello";
};

My current theory is that #string_context should be under #paremeter, rather than #function_parameter_context.
That does seem to fix this issue