On Sat, Mar 23, 2013 at 04:31:42AM -0500, Sung Pae wrote:
> On Tue, Mar 19, 2013 at 03:28:07PM +0100, Bram Moolenaar wrote:
> >
> > Patch 7.3.871
> > Problem:    search('^$', 'c') does not use the empty match under the cursor.
> > Solution:   Special handling of the 'c' flag. (Christian Brabandt)
> >         Add tests.
> > Files:          src/search.c, src/testdir/test14.in, > src/testdir/test14.ok
>
> Unfortunately, this patch breaks forward searching with the SEARCH_START
> flag set:
>
>     foo bar| baz " Cursor at |
>
> :call search('.', 'c')
>
> This places the cursor at column 1 instead of staying put as expected.
> The problem is that simply breaking the column advance loop if
> SEARCH_START is set will break all searches instead of just ones for the
> empty line "^$".
>
> Since matches at an empty line result in matchcol == 0, adding that to
> the conditional fixes just that corner case without affecting all other
> searches with the 'c' flag.
>
> Simple patch is attached.
>
>     Sung Pae

Actually attach patch.
From ad1e004393c6949b99ca4324d609b1dcf3391286 Mon Sep 17 00:00:00 2001
From: guns <[email protected]>
Date: Sat, 23 Mar 2013 04:19:55 -0500
Subject: [PATCH] Fix broken forward search with SEARCH_START

Patch 7.3.871 introduced a change to fix forward searches for empty
lines. Unfortunately, it also broke forward search() with the 'c' flag.

This patch focuses the change introduced by 7.3.871 to matches of empty
lines.
---
 src/search.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/search.c b/src/search.c
index 934e4b0..c8dd6da 100644
--- a/src/search.c
+++ b/src/search.c
@@ -727,7 +727,7 @@ searchit(win, buf, pos, dir, pat, count, options, pat_use, 
stop_lnum, tm)
                                        ++matchcol;
                                }
                            }
-                           if (options & SEARCH_START)
+                           if (matchcol == 0 && options & SEARCH_START)
                                break;
                            if (ptr[matchcol] == NUL
                                    || (nmatched = vim_regexec_multi(&regmatch,
-- 
1.8.2

Attachment: pgpc2dWnh3GDL.pgp
Description: PGP signature

Raspunde prin e-mail lui