Skip to content

Commit 4c15bbf

Browse files
committed
core: Fix matching with nested braces (#160)
Port the change from <editorconfig/editorconfig-core-py#33> to this core.
1 parent 89ca35f commit 4c15bbf

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

autoload/editorconfig_core/fnmatch.vim

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,24 @@ if !exists('g:editorconfig_core_vimscript_debug')
4545
endif
4646
" }}}1
4747
" === Regexes =========================================================== {{{1
48-
let s:LEFT_BRACE = '\v%(^|[^\\])\{'
48+
let s:LEFT_BRACE = '\v[\\]@8<!\{'
49+
" 8 is an arbitrary byte-count limit to the lookbehind (micro-optimization)
4950
"LEFT_BRACE = re.compile(
5051
" r"""
5152
"
52-
" (?: ^ | [^\\] ) # Beginning of string or a character besides "\"
53+
" (?<! \\ ) # Not preceded by "\"
5354
"
5455
" \{ # "{"
5556
"
5657
" """, re.VERBOSE
5758
")
5859

59-
let s:RIGHT_BRACE = '\v%(^|[^\\])\}'
60+
let s:RIGHT_BRACE = '\v[\\]@8<!\}'
61+
" 8 is an arbitrary byte-count limit to the lookbehind (micro-optimization)
6062
"RIGHT_BRACE = re.compile(
6163
" r"""
6264
"
63-
" (?: ^ | [^\\] ) # Beginning of string or a character besides "\"
65+
" (?<! \\ ) # Not preceded by "\"
6466
"
6567
" \} # "}"
6668
"

0 commit comments

Comments
 (0)