Skip to content

Commit 2764fd3

Browse files
committed
^ and $ is always meta character in very magic mode
1 parent 2bdde8d commit 2764fd3

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

autoload/vimlparser.vim

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4308,23 +4308,25 @@ function s:RegexpParser.parse_regexp()
43084308
endif
43094309
elseif ntoken ==# '\^'
43104310
" '^' is only magic as the very first character.
4311-
if prevtoken !=# '' && prevtoken !=# '\&' && prevtoken !=# '\|' && prevtoken !=# '\n' && prevtoken !=# '\(' && prevtoken !=# '\%('
4311+
if self.reg_magic != self.RE_VERY_MAGIC && prevtoken !=# '' && prevtoken !=# '\&' && prevtoken !=# '\|' && prevtoken !=# '\n' && prevtoken !=# '\(' && prevtoken !=# '\%('
43124312
let ntoken = '^'
43134313
endif
43144314
elseif ntoken ==# '\$'
43154315
" '$' is only magic as the very last character
43164316
let pos = self.reader.tell()
4317-
while !self.isend(self.reader.peek())
4318-
let [t, n] = self.get_token()
4319-
" XXX: Vim doesn't check \v and \V?
4320-
if n ==# '\c' || n ==# '\C' || n ==# '\m' || n ==# '\M' || n ==# '\Z'
4321-
continue
4322-
endif
4323-
if n !=# '\|' && n !=# '\&' && n !=# '\n' && n !=# '\)'
4324-
let ntoken = '$'
4325-
endif
4326-
break
4327-
endwhile
4317+
if self.reg_magic != self.RE_VERY_MAGIC
4318+
while !self.isend(self.reader.peek())
4319+
let [t, n] = self.get_token()
4320+
" XXX: Vim doesn't check \v and \V?
4321+
if n ==# '\c' || n ==# '\C' || n ==# '\m' || n ==# '\M' || n ==# '\Z'
4322+
continue
4323+
endif
4324+
if n !=# '\|' && n !=# '\&' && n !=# '\n' && n !=# '\)'
4325+
let ntoken = '$'
4326+
endif
4327+
break
4328+
endwhile
4329+
endif
43284330
call self.reader.seek_set(pos)
43294331
elseif ntoken ==# '\?'
43304332
" '?' is literal in '?' command.

0 commit comments

Comments
 (0)