Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Fix C++ synatx highlighting error in macros with extern "C" #271

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions grammars/c++.cson
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
10 changes: 10 additions & 0 deletions spec/c-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down