Microsoft/monaco-editor

[Bug] C++ Raw strings aren't properly handled when the delimiter contains a quote

Open

#3,245 建立於 2022年8月15日

在 GitHub 查看
 (0 留言) (0 反應) (0 負責人)JavaScript (1,283 fork)batch import
buggrammarshelp wantedlanguages-basic

倉庫指標

Star
 (14,836 star)
PR 合併指標
 (平均合併 6小時 26分鐘) (30 天內合併 15 個 PR)

描述

Reproducible in vscode.dev or in VS Code Desktop?

  • Not reproducible in vscode.dev or VS Code Desktop

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"]*))(\")/,

貢獻者指南