You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Backreferences are supposed to match the text that the nominated group matched. But once .* and \n are involved in the group, the regular expression engine can match different text in the backreference, allowing the backreference to kind of expand the .* a second time.
To Reproduce
Detailed steps to reproduce the behavior:
Run vim --clean (or gvim --clean, etc.)
Insert the following:
foo
bar
barnaby
baz
Search for any duplicated lines: /\(^.*\n\)\1<Enter>
Observe that this matches bar\nbarnaby\n. (It’s like it searched for \(^.*\)\n\1.*\n instead.)
Expected behavior
There should be no matches: in the case that did match, \1 is bar\n, which is different from “barn\n”.
(\(^.*$\)\n\1\n does not exhibit this bug.)
Environment (please complete the following information):
Vim 8.2.814
OS: Arch Linux
The text was updated successfully, but these errors were encountered:
It looks like the bug has nothing to do with .*, just with backreferences to groups ending in a newline: @chris-morgan's example still works if you search for ^\(bar\n\)\1 instead of ^\(.*\n\)\1. Similarly, replacing .* by foo in my previous comment does not change the results.
Describe the bug
Backreferences are supposed to match the text that the nominated group matched. But once
.*
and\n
are involved in the group, the regular expression engine can match different text in the backreference, allowing the backreference to kind of expand the.*
a second time.To Reproduce
Detailed steps to reproduce the behavior:
vim --clean
(orgvim --clean
, etc.)bar\nbarnaby\n
. (It’s like it searched for\(^.*\)\n\1.*\n
instead.)Expected behavior
There should be no matches: in the case that did match,
\1
isbar\n
, which is different from “barn\n”.(
\(^.*$\)\n\1\n
does not exhibit this bug.)Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: