microsoft / microsoft/monaco-editor
[Bug] C++ Raw strings aren't properly handled when the delimiter contains a quote
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 46.8k
- Forks
- 4.1k
- Avg merge
- 17h 58m
- Merged PRs (30d)
- 1
Description
Reproducible in vscode.dev or in VS Code Desktop?
- Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
- Not reproducible in the monaco editor playground
Monaco Editor Playground Code
monaco.editor.create(document.getElementById('container'), {
value: `
int main() {
auto _ = R""( content )"";
}`,
language: 'cpp'
});
Reproduction Steps
paste the code in the js section and observe the resulting highlight being wrong
Actual (Problematic) Behavior
The raw string end isn't properly detected and the string highlighting continues until the end of the file
Expected Behavior
the raw string's end is properly detected
Additional Context
C++ raw string have the form R"delimiter(content)delimiter" where the delimiter is a (possibly empty) sequence of characters that may include quotes. when the delimiter contains quotes, the end isn't properly detected. having looked at the sources, while I don't understand everything, it looks a lot like this regex is responsible, as it exclude the quotes from the characters making up the delimiter (there's a mismatch with the regex for the opening delimiter):
raw: [
[
/(.*)(\))(?:([^ ()\\\t"]*))(\")/,
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/basic-languages/cpp/cpp.ts, especially the raw-string rule linked in the report, and reproduce the highlighting in the Monaco Editor Playground using the supplied TypeScript snippet. Compare the opening and closing delimiter patterns; done means the closing delimiter is detected when it contains quotes and highlighting stops at the raw string’s end.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100