Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim positive lookbehind bug?

Enter this in a file:

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

Hello
A

Hello
B

And then search for this using /:

\(Hello\n\)\@<=A

On my version of Vim (7.4, included patches: 1-582), the A underneath Hello is matched as expected, B is not, but also the 446th A on the first line is matched.

There is also some weird behaviour with this, if I make the line longer with more As, the 632nd A is highlighted. If I introduce 16 spaces at the beginning of the line, the 447th and the 632nd characters on the line are matched.

My question is, does this affect anyone else, and is it really a bug or is my search erroneous?

like image 820
texasflood Avatar asked Sep 29 '22 18:09

texasflood


1 Answers

Yes, this looks like a bug. I can reproduce with Vim 7.4.608, but only with the default :set regexpengine=0 automatic selection.

To avoid the problem, you can either change the global option, or explicitly specify an engine inside the pattern:

\%#=1\(Hello\n\)\@<=A
\%#=2\(Hello\n\)\@<=A

Please report this bug, either to the vim_dev mailing list, or its issue tracker.

like image 171
Ingo Karkat Avatar answered Oct 05 '22 07:10

Ingo Karkat