From a3dfccc6e9a780570166b00c0e40c4b9a149e253 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 27 Nov 2014 17:29:56 +0100 Subject: updated for version 7.4.532 Problem: When using 'incsearch' "2/pattern/e" highlights the first match. Solution: Move the code to set extra_col inside the loop for count. (Ozaki Kiichi) --- src/search.c | 46 ++++++++++++++++++++++++---------------------- src/version.c | 2 ++ 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/search.c b/src/search.c index 283e77867e..047a733972 100644 --- a/src/search.c +++ b/src/search.c @@ -552,6 +552,7 @@ searchit(win, buf, pos, dir, pat, count, options, pat_use, stop_lnum, tm) int match_ok; long nmatched; int submatch = 0; + int first_match = TRUE; int save_called_emsg = called_emsg; #ifdef FEAT_SEARCH_EXTRA int break_loop = FALSE; @@ -565,33 +566,33 @@ searchit(win, buf, pos, dir, pat, count, options, pat_use, stop_lnum, tm) return FAIL; } - /* When not accepting a match at the start position set "extra_col" to a - * non-zero value. Don't do that when starting at MAXCOL, since MAXCOL + - * 1 is zero. */ - if ((options & SEARCH_START) || pos->col == MAXCOL) - extra_col = 0; -#ifdef FEAT_MBYTE - /* Watch out for the "col" being MAXCOL - 2, used in a closed fold. */ - else if (dir != BACKWARD && has_mbyte - && pos->lnum >= 1 && pos->lnum <= buf->b_ml.ml_line_count - && pos->col < MAXCOL - 2) - { - ptr = ml_get_buf(buf, pos->lnum, FALSE) + pos->col; - if (*ptr == NUL) - extra_col = 1; - else - extra_col = (*mb_ptr2len)(ptr); - } -#endif - else - extra_col = 1; - /* * find the string */ called_emsg = FALSE; do /* loop for count */ { + /* When not accepting a match at the start position set "extra_col" to + * a non-zero value. Don't do that when starting at MAXCOL, since + * MAXCOL + 1 is zero. */ + if ((options & SEARCH_START) || pos->col == MAXCOL) + extra_col = 0; +#ifdef FEAT_MBYTE + /* Watch out for the "col" being MAXCOL - 2, used in a closed fold. */ + else if (dir != BACKWARD && has_mbyte + && pos->lnum >= 1 && pos->lnum <= buf->b_ml.ml_line_count + && pos->col < MAXCOL - 2) + { + ptr = ml_get_buf(buf, pos->lnum, FALSE) + pos->col; + if (*ptr == NUL) + extra_col = 1; + else + extra_col = (*mb_ptr2len)(ptr); + } +#endif + else + extra_col = 1; + start_pos = *pos; /* remember start pos for detecting no match */ found = 0; /* default: not found */ at_first_line = TRUE; /* default: start in first line */ @@ -677,7 +678,7 @@ searchit(win, buf, pos, dir, pat, count, options, pat_use, stop_lnum, tm) * otherwise "/$" will get stuck on end of line. */ while (matchpos.lnum == 0 - && ((options & SEARCH_END) + && ((options & SEARCH_END) && first_match ? (nmatched == 1 && (int)endpos.col - 1 < (int)start_pos.col + extra_col) @@ -908,6 +909,7 @@ searchit(win, buf, pos, dir, pat, count, options, pat_use, stop_lnum, tm) pos->coladd = 0; #endif found = 1; + first_match = FALSE; /* Set variables used for 'incsearch' highlighting. */ search_match_lines = endpos.lnum - matchpos.lnum; diff --git a/src/version.c b/src/version.c index 38acd5da2d..fd7c414692 100644 --- a/src/version.c +++ b/src/version.c @@ -741,6 +741,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 532, /**/ 531, /**/ -- cgit v1.2.3