Skip to content

Commit

Permalink
fix for #203
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-hykin committed May 25, 2019
1 parent 5eed0af commit eb7a6f3
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 3 deletions.
6 changes: 5 additions & 1 deletion cpp/generate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,11 @@ def generateBlockFinder( name:"", tag_as:"", start_pattern:nil, needs_semicolon:
# e.g. std::string ("hello");
:function_call_context,
]
)
),
:comments_context,
# initial context is here for things like noexcept()
# TODO: fix this pattern an make it more strict
:$initial_context
],
needs_semicolon: false,
body_includes: [ :type_casting_operators, :function_call, :$initial_context ],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Better C++ Syntax",
"description": "The bleeding edge of the VS Code C++ syntax",
"icon": "icon.png",
"version": "1.9.5",
"version": "1.9.6",
"scripts": {
"build": "ruby cpp/generate.rb && ruby c/generate.rb",
"pretest": "npm run build",
Expand Down
6 changes: 6 additions & 0 deletions syntaxes/cpp.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -2062,6 +2062,12 @@
"include": "#function_call_context"
}
]
},
{
"include": "#comments_context"
},
{
"include": "$base"
}
]
},
Expand Down
2 changes: 2 additions & 0 deletions syntaxes/cpp.tmLanguage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,8 @@
patterns:
- include: "#function_parameter_context"
- include: "#function_call_context"
- include: "#comments_context"
- include: "$base"
- name: meta.body.function.definition.cpp
begin: "(?<=\\{)"
end: "(\\})"
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/issues/203.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// another comment
int fun() /* a comment */ // test
{
return 1; /* a comment */ // test
}
9 changes: 8 additions & 1 deletion test/specs/issues/085.cpp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,14 @@
- source: )
scopes:
- punctuation.section.parameters.end.bracket.round
- source: ' // this one is not'
- source: //
scopesBegin:
- comment.line.double-slash
scopes:
- punctuation.definition.comment
- source: ' this one is not'
scopesEnd:
- comment.line.double-slash
- source: '{'
scopes:
- punctuation.section.block.begin.bracket.curly.function.definition
Expand Down
82 changes: 82 additions & 0 deletions test/specs/issues/203.cpp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
- source: //
scopesBegin:
- comment.line.double-slash
scopes:
- punctuation.definition.comment
- source: ' another comment'
scopesEnd:
- comment.line.double-slash
- source: int
scopesBegin:
- meta.function.definition
scopes:
- meta.qualified_type
- storage.type.primitive
- source: fun
scopesBegin:
- meta.head.function.definition
scopes:
- entity.name.function.definition
- source: (
scopes:
- punctuation.section.parameters.begin.bracket.round
- source: )
scopes:
- punctuation.section.parameters.end.bracket.round
- source: /*
scopesBegin:
- comment.block
scopes:
- punctuation.definition.comment.begin
- source: ' a comment '
- source: '*/'
scopes:
- punctuation.definition.comment.end
scopesEnd:
- comment.block
- source: //
scopesBegin:
- comment.line.double-slash
scopes:
- punctuation.definition.comment
- source: ' test'
scopesEnd:
- comment.line.double-slash
- source: '{'
scopes:
- punctuation.section.block.begin.bracket.curly.function.definition
scopesEnd:
- meta.head.function.definition
- source: return
scopesBegin:
- meta.body.function.definition
scopes:
- keyword.control.return
- source: '1'
scopes:
- constant.numeric.decimal
- source: ;
scopes:
- punctuation.terminator.statement
- source: /*
scopesBegin:
- comment.block
scopes:
- punctuation.definition.comment.begin
- source: ' a comment '
- source: '*/'
scopes:
- punctuation.definition.comment.end
scopesEnd:
- comment.block
- source: //
scopesBegin:
- comment.line.double-slash
scopes:
- punctuation.definition.comment
- source: ' test'
scopesEnd:
- comment.line.double-slash
- source: '}'
scopes:
- punctuation.section.block.end.bracket.curly.function.definition

0 comments on commit eb7a6f3

Please sign in to comment.