aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Bürgin <676c7473@gmail.com>2015-04-25 12:14:49 +0200
committerJustin M. Keyes <justinkz@gmail.com>2015-04-27 01:46:43 -0400
commitaf863d46a99aa5d14ff7524dbf17764520554f2b (patch)
treed539f1210c5f11e56dfa4393ecb7bbfd557bfed2 /src
parent0928904e16a8cc68492732c773931fcedf7efdac (diff)
downloadrneovim-af863d46a99aa5d14ff7524dbf17764520554f2b.tar.gz
rneovim-af863d46a99aa5d14ff7524dbf17764520554f2b.tar.bz2
rneovim-af863d46a99aa5d14ff7524dbf17764520554f2b.zip
vim-patch:7.4.532 #2504
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) https://github.com/vim/vim/releases/tag/v7-4-532
Diffstat (limited to 'src')
-rw-r--r--src/nvim/search.c36
-rw-r--r--src/nvim/version.c2
2 files changed, 19 insertions, 19 deletions
diff --git a/src/nvim/search.c b/src/nvim/search.c
index d20bd77289..59d6cf4427 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -469,6 +469,7 @@ int searchit(
int match_ok;
long nmatched;
int submatch = 0;
+ bool first_match = true;
int save_called_emsg = called_emsg;
int break_loop = FALSE;
@@ -479,28 +480,26 @@ int searchit(
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;
- /* 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);
- } 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;
+ } else if (dir != BACKWARD && has_mbyte
+ && pos->lnum >= 1 && pos->lnum <= buf->b_ml.ml_line_count
+ && pos->col < MAXCOL - 2) {
+ // Watch out for the "col" being MAXCOL - 2, used in a closed fold.
+ ptr = ml_get_buf(buf, pos->lnum, FALSE) + pos->col;
+ extra_col = *ptr == NUL ? 1 : (*mb_ptr2len)(ptr);
+ } 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 */
@@ -571,7 +570,7 @@ int searchit(
* 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)
@@ -753,6 +752,7 @@ int searchit(
}
pos->coladd = 0;
found = 1;
+ first_match = false;
/* Set variables used for 'incsearch' highlighting. */
search_match_lines = endpos.lnum - matchpos.lnum;
diff --git a/src/nvim/version.c b/src/nvim/version.c
index d4c2a42250..8ef6ae8ee8 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -237,7 +237,7 @@ static int included_patches[] = {
//535,
//534 NA
533,
- //532,
+ 532,
//531,
//530,
529,