diff options
author | Bram Moolenaar <Bram@vim.org> | 2014-11-27 17:29:56 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2014-11-27 17:29:56 +0100 |
commit | a3dfccc6e9a780570166b00c0e40c4b9a149e253 (patch) | |
tree | 217b696c276c47f5ef7c32d487132ff4e79e8138 /src/search.c | |
parent | 1c40a66badd83e9a93116c006097033725c9eb7d (diff) | |
download | vim-git-a3dfccc6e9a780570166b00c0e40c4b9a149e253.tar.gz |
updated for version 7.4.532v7.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)
Diffstat (limited to 'src/search.c')
-rw-r--r-- | src/search.c | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/src/search.c b/src/search.c index 283e77867..047a73397 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; |