From 7b96ed2fbd0479eca5d56eeba208ac2fadb85360 Mon Sep 17 00:00:00 2001 From: nreed Date: Sat, 26 Jun 2021 11:33:33 -0400 Subject: [PATCH 1/3] fix c++ comment continuation highlighting #2497 --- src/cpp/cpp.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cpp/cpp.ts b/src/cpp/cpp.ts index 525b2551..6402bbd9 100644 --- a/src/cpp/cpp.ts +++ b/src/cpp/cpp.ts @@ -347,10 +347,12 @@ export const language = { [/[ \t\r\n]+/, ''], [/\/\*\*(?!\/)/, 'comment.doc', '@doccomment'], [/\/\*/, 'comment', '@comment'], + [/\/\/.*\\$/, 'comment', '@comment'], [/\/\/.*$/, 'comment'] ], comment: [ + [/.*[^\\]$/, 'comment', '@pop'], [/[^\/*]+/, 'comment'], [/\*\//, 'comment', '@pop'], [/[\/*]/, 'comment'] From 4dbc07d55700beb666a4006bbe05979862530ec4 Mon Sep 17 00:00:00 2001 From: nreed Date: Mon, 5 Jul 2021 11:27:32 -0400 Subject: [PATCH 2/3] Changed to use linecomment for continuation comments --- src/cpp/cpp.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/cpp/cpp.ts b/src/cpp/cpp.ts index 6402bbd9..77beaa09 100644 --- a/src/cpp/cpp.ts +++ b/src/cpp/cpp.ts @@ -347,16 +347,22 @@ export const language = { [/[ \t\r\n]+/, ''], [/\/\*\*(?!\/)/, 'comment.doc', '@doccomment'], [/\/\*/, 'comment', '@comment'], - [/\/\/.*\\$/, 'comment', '@comment'], + [/\/\/.*\\$/, 'comment', '@linecomment'], [/\/\/.*$/, 'comment'] ], comment: [ - [/.*[^\\]$/, 'comment', '@pop'], [/[^\/*]+/, 'comment'], [/\*\//, 'comment', '@pop'], [/[\/*]/, 'comment'] ], + + //For use with continuous line comments + linecomment: [ + [/.*[^\\]$/, 'comment', '@pop'], + [/[^]+/, 'comment'] + ], + //Identical copy of comment above, except for the addition of .doc doccomment: [ [/[^\/*]+/, 'comment.doc'], From f85fd5388eeee3e9c658f7a346eb64c9f686876a Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Wed, 14 Jul 2021 09:30:17 +0200 Subject: [PATCH 3/3] Add test --- src/cpp/cpp.test.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/cpp/cpp.test.ts b/src/cpp/cpp.test.ts index ddd7b865..b776103f 100644 --- a/src/cpp/cpp.test.ts +++ b/src/cpp/cpp.test.ts @@ -950,5 +950,30 @@ testTokenization('cpp', [ { startIndex: 22, type: 'keyword.directive.include.end.cpp' } ] } + ], + + [ + // microsoft/monaco-editor#2497 : comment continuation highlighting + { + line: '// this is a comment \\', + tokens: [{ startIndex: 0, type: 'comment.cpp' }] + }, + { + line: 'this is still a comment', + tokens: [{ startIndex: 0, type: 'comment.cpp' }] + }, + { + line: 'int x = 1;', + tokens: [ + { startIndex: 0, type: 'keyword.int.cpp' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.cpp' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.cpp' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'number.cpp' }, + { startIndex: 9, type: 'delimiter.cpp' } + ] + } ] ]);