Browse Source

Fixes https://github.com/microsoft/monaco-editor/issues/1951

Alex Dima 4 years ago
parent
commit
9c57d47b94
2 changed files with 31 additions and 1 deletions
  1. 30 0
      src/cpp/cpp.test.ts
  2. 1 1
      src/cpp/cpp.ts

+ 30 - 0
src/cpp/cpp.test.ts

@@ -828,5 +828,35 @@ testTokenization('cpp', [
 				{ startIndex: 19, type: 'identifier.cpp' }
 				{ startIndex: 19, type: 'identifier.cpp' }
 			]
 			]
 		}
 		}
+	],
+
+	// https://github.com/microsoft/monaco-editor/issues/1951
+	[
+		{
+			line: 'auto sv = R"({ "message": "Hello World" })""\\n"sv;',
+			tokens: [
+				{ startIndex: 0, type: 'keyword.auto.cpp' },
+				{ startIndex: 4, type: '' },
+				{ startIndex: 5, type: 'identifier.cpp' },
+				{ startIndex: 7, type: '' },
+				{ startIndex: 8, type: 'delimiter.cpp' },
+				{ startIndex: 9, type: '' },
+				{ startIndex: 10, type: 'string.raw.begin.cpp' },
+				{ startIndex: 13, type: 'string.raw.cpp' },
+				{ startIndex: 41, type: 'string.raw.end.cpp' },
+				{ startIndex: 43, type: 'string.cpp' },
+				{ startIndex: 44, type: 'string.escape.cpp' },
+				{ startIndex: 46, type: 'string.cpp' },
+				{ startIndex: 47, type: 'identifier.cpp' },
+				{ startIndex: 49, type: 'delimiter.cpp' }
+			]
+		},
+		{
+			line: '    // This is a comment, not a string',
+			tokens: [
+				{ startIndex: 0, type: '' },
+				{ startIndex: 4, type: 'comment.cpp' }
+			]
+		}
 	]
 	]
 ]);
 ]);

+ 1 - 1
src/cpp/cpp.ts

@@ -377,7 +377,7 @@ export const language = <ILanguage>{
 
 
 		raw: [
 		raw: [
 			[
 			[
-				/(.*)(\))(?:([^ ()\\\t]*))(\")/,
+				/(.*)(\))(?:([^ ()\\\t"]*))(\")/,
 				{
 				{
 					cases: {
 					cases: {
 						'$3==$S2': [
 						'$3==$S2': [