patch 8.0.1238: incremental search only shows one match
Problem: Incremental search only shows one match.
Solution: When 'incsearch' and and 'hlsearch' are both set highlight all
matches. (haya14busa, closes #2198)
diff --git a/src/ex_getln.c b/src/ex_getln.c
index ba6a403..717a012 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -1715,8 +1715,9 @@
if (p_is && !cmd_silent && (firstc == '/' || firstc == '?'))
{
pos_T t;
- int search_flags = SEARCH_KEEP + SEARCH_NOOF;
+ int search_flags = SEARCH_NOOF;
+ save_last_search_pattern();
cursor_off();
out_flush();
if (c == Ctrl_G)
@@ -1726,6 +1727,8 @@
}
else
t = match_start;
+ if (!p_hls)
+ search_flags += SEARCH_KEEP;
++emsg_off;
i = searchit(curwin, curbuf, &t,
c == Ctrl_G ? FORWARD : BACKWARD,
@@ -1777,6 +1780,7 @@
# endif
old_botline = curwin->w_botline;
update_screen(NOT_VALID);
+ restore_last_search_pattern();
redrawcmdline();
}
else
@@ -1934,12 +1938,17 @@
}
incsearch_postponed = FALSE;
curwin->w_cursor = search_start; /* start at old position */
+ save_last_search_pattern();
/* If there is no command line, don't do anything */
if (ccline.cmdlen == 0)
+ {
i = 0;
+ SET_NO_HLSEARCH(TRUE); /* turn off previous highlight */
+ }
else
{
+ int search_flags = SEARCH_OPT + SEARCH_NOOF + SEARCH_PEEK;
cursor_off(); /* so the user knows we're busy */
out_flush();
++emsg_off; /* So it doesn't beep if bad expr */
@@ -1947,8 +1956,10 @@
/* Set the time limit to half a second. */
profile_setlimit(500L, &tm);
#endif
+ if (!p_hls)
+ search_flags += SEARCH_KEEP;
i = do_search(NULL, firstc, ccline.cmdbuff, count,
- SEARCH_KEEP + SEARCH_OPT + SEARCH_NOOF + SEARCH_PEEK,
+ search_flags,
#ifdef FEAT_RELTIME
&tm, NULL
#else
@@ -2005,6 +2016,7 @@
save_cmdline(&save_ccline);
update_screen(SOME_VALID);
restore_cmdline(&save_ccline);
+ restore_last_search_pattern();
/* Leave it at the end to make CTRL-R CTRL-W work. */
if (i != 0)