From dc477a01857d0d6a8d7d77cbb699d25fb8673a51 Mon Sep 17 00:00:00 2001 From: Sergey Zolotarev Date: Thu, 12 Apr 2018 04:38:02 +0600 Subject: [PATCH] WIP Fix C++ synatx highlighting error in macros with extern "C" --- grammars/c++.cson | 6 +++--- spec/c-spec.coffee | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/grammars/c++.cson b/grammars/c++.cson index 16dc335..d698e43 100644 --- a/grammars/c++.cson +++ b/grammars/c++.cson @@ -341,15 +341,15 @@ 'beginCaptures': '1': 'name': 'storage.modifier.cpp' - 'end': '(?<=\\})|(?=\\w)|(?=\\s*#\\s*endif\\b)' + 'end': '(?<=})|(?=\\w)|(?=\\s*#\\s*(?:elif|else|endif)\\b)' 'name': 'meta.extern-block.cpp' 'patterns': [ { - 'begin': '\\{' + 'begin': '{' 'beginCaptures': '0': 'name': 'punctuation.section.block.begin.bracket.curly.c' - 'end': '\\}|(?=\\s*#\\s*endif\\b)' + 'end': '}|(?=\\s*#\\s*(?:elif|else|endif)\\b)' 'endCaptures': '0': 'name': 'punctuation.section.block.end.bracket.curly.c' diff --git a/spec/c-spec.coffee b/spec/c-spec.coffee index 7a1ff5e..b4814ec 100644 --- a/spec/c-spec.coffee +++ b/spec/c-spec.coffee @@ -1001,6 +1001,16 @@ describe "Language-C", -> expect(lines[6][0]).toEqual value: '#', scopes: ['source.cpp', 'meta.preprocessor.c', 'keyword.control.directive.conditional.c', 'punctuation.definition.directive.c'] expect(lines[6][1]).toEqual value: 'endif', scopes: ['source.cpp', 'meta.preprocessor.c', 'keyword.control.directive.conditional.c'] + lines = grammar.tokenizeLines ''' + #ifdef __cplusplus + #define EXTERN extern "C" + #else + #define EXTERN extern + #endif + ''' + # TODO + expect(lines).toEqual false + it "tokenizes UTF string escapes", -> lines = grammar.tokenizeLines ''' string str = U"\\U01234567\\u0123\\"\\0123\\x123";