# HG changeset patch # User Bram Moolenaar # Date 1365016469 -7200 # Node ID 96f478b812b14fb1a5710450a1174baa55c73409 # Parent 0c618ae9b04059cdb2e8ed09523af8a9eec426c1 updated for version 7.3.877 Problem: Forward searching with search() is broken. Solution: Fix it and add tests. (Sung Pae) diff --git a/src/search.c b/src/search.c --- a/src/search.c +++ b/src/search.c @@ -727,7 +727,7 @@ searchit(win, buf, pos, dir, pat, count, ++matchcol; } } - if (options & SEARCH_START) + if (matchcol == 0 && (options & SEARCH_START)) break; if (ptr[matchcol] == NUL || (nmatched = vim_regexec_multi(®match, @@ -869,7 +869,7 @@ searchit(win, buf, pos, dir, pat, count, /* With the SEARCH_END option move to the last character * of the match. Don't do it for an empty match, end * should be same as start then. */ - if (options & SEARCH_END && !(options & SEARCH_NOOF) + if ((options & SEARCH_END) && !(options & SEARCH_NOOF) && !(matchpos.lnum == endpos.lnum && matchpos.col == endpos.col)) { diff --git a/src/testdir/test14.in b/src/testdir/test14.in --- a/src/testdir/test14.in +++ b/src/testdir/test14.in @@ -44,6 +44,9 @@ j:call search('^$', 'c') :call append(line('$'), line('.') - startline) :call search('^$', 'bc') :call append(line('$'), line('.') - startline) +/two +:call search('.', 'c') +:call append(line('$'), getline('.')[col('.') - 1:]) :/^search()/,$w >>test.out :qa! ENDTEST @@ -79,4 +82,5 @@ Piece of Java foobar +one two search() diff --git a/src/testdir/test14.ok b/src/testdir/test14.ok --- a/src/testdir/test14.ok +++ b/src/testdir/test14.ok @@ -19,3 +19,4 @@ search() 0 1 1 +two diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -729,6 +729,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 877, +/**/ 876, /**/ 875,