Skip to content

Commit

Permalink
initial attempt at not matching comments in macros
Browse files Browse the repository at this point in the history
Fixes #506.
  • Loading branch information
matter123 committed Nov 6, 2020
1 parent ddc1a81 commit 9c4d17e
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 50 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@
"dependencies": {
"textmate-bailout": "^1.1.0"
}
}
}
3 changes: 2 additions & 1 deletion source/languages/cpp/lib/preprocessor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ def wordBounds(regex_pattern)
#
grammar[:single_line_macro] = Pattern.new(
should_fully_match: ['#define EXTERN_C extern "C"'],
match: /^/.then(std_space).then(/#define/).then(/.*/).lookBehindToAvoid(/[\\]/).then(@end_of_line),
should_not_partial_match: ['#define test /* partial comment'],
match: /^/.then(std_space).then(/#define/).oneOrMoreOf(oneOf([/[^\/]+/, /\/(?:[^*]|$)/])).lookBehindToAvoid(/[\\]/).then(@end_of_line),
includes: [
:macro,
:comments,
Expand Down
2 changes: 1 addition & 1 deletion syntaxes/cpp.embedded.macro.tmLanguage.json

Large diffs are not rendered by default.

0 comments on commit 9c4d17e

Please sign in to comment.