vim-patch:7.4.636 #2267

Problem:    A search with end offset gets stuck at end of file. (Gary Johnson)
Solution:   When a search doesn't move the cursor repeat it with a higher
            count. (Christian Brabandt)

https://github.com/vim/vim/releases/tag/v7-4-636
This commit is contained in:
David Bürgin 2015-03-27 09:34:54 +01:00 committed by Justin M. Keyes
parent 23425a3a6e
commit 7a5a85d2c4
4 changed files with 25 additions and 6 deletions

View File

@ -4361,7 +4361,7 @@ static void nv_ident(cmdarg_T *cap)
/* put pattern in search history */ /* put pattern in search history */
init_history(); init_history();
add_to_history(HIST_SEARCH, buf, true, NUL); add_to_history(HIST_SEARCH, buf, true, NUL);
normal_search(cap, cmdchar == '*' ? '/' : '?', buf, 0); (void)normal_search(cap, cmdchar == '*' ? '/' : '?', buf, 0);
} else } else
do_cmdline_cmd(buf); do_cmdline_cmd(buf);
@ -4785,7 +4785,7 @@ static void nv_search(cmdarg_T *cap)
return; return;
} }
normal_search(cap, cap->cmdchar, cap->searchbuf, (void)normal_search(cap, cap->cmdchar, cap->searchbuf,
(cap->arg ? 0 : SEARCH_MARK)); (cap->arg ? 0 : SEARCH_MARK));
} }
@ -4795,15 +4795,25 @@ static void nv_search(cmdarg_T *cap)
*/ */
static void nv_next(cmdarg_T *cap) static void nv_next(cmdarg_T *cap)
{ {
normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg); pos_T old = curwin->w_cursor;
int i = normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg);
if (i == 1 && equalpos(old, curwin->w_cursor)) {
// Avoid getting stuck on the current cursor position, which can happen when
// an offset is given and the cursor is on the last char in the buffer:
// Repeat with count + 1.
cap->count1 += 1;
(void)normal_search(cap, 0, NULL, SEARCH_MARK | cap->arg);
cap->count1 -= 1;
}
} }
/* /*
* Search for "pat" in direction "dir" ('/' or '?', 0 for repeat). * Search for "pat" in direction "dir" ('/' or '?', 0 for repeat).
* Uses only cap->count1 and cap->oap from "cap". * Uses only cap->count1 and cap->oap from "cap".
* Return 0 for failure, 1 for found, 2 for found and line offset added.
*/ */
static void static int normal_search(
normal_search (
cmdarg_T *cap, cmdarg_T *cap,
int dir, int dir,
char_u *pat, char_u *pat,
@ -4832,6 +4842,7 @@ normal_search (
/* "/$" will put the cursor after the end of the line, may need to /* "/$" will put the cursor after the end of the line, may need to
* correct that here */ * correct that here */
check_cursor(); check_cursor();
return i;
} }
/* /*

View File

@ -42,6 +42,12 @@ G:put =matchstr(\"אבגד\", \".\", 0, 2) " ב
:put =matchstr(\"אבגד\", \"..\", 0, 2) " בג :put =matchstr(\"אבגד\", \"..\", 0, 2) " בג
:put =matchstr(\"אבגד\", \".\", 0, 0) " א :put =matchstr(\"אבגד\", \".\", 0, 0) " א
:put =matchstr(\"אבגד\", \".\", 4, -1) " ג :put =matchstr(\"אבגד\", \".\", 4, -1) " ג
:new
:$put =['dog(a', 'cat(']
/(/e+
"ayn:bd!
:$put =''
G"ap
:w! :w!
:qa! :qa!
ENDTEST ENDTEST

View File

@ -22,3 +22,5 @@ k œ̄ṣ́m̥̄ᾱ̆́
בג בג
א א
ג ג
a
cat(

View File

@ -104,7 +104,7 @@ static int included_patches[] = {
//639, //639,
//638, //638,
637, 637,
//636, 636,
//635, //635,
//634, //634,
//633, //633,