diff src/ex_getln.c @ 12720:37c384802df4 v8.0.1238

patch 8.0.1238: incremental search only shows one match commit https://github.com/vim/vim/commit/2e51d9a0972080b087d566608472928d5b7b35d7 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Oct 29 16:40:30 2017 +0100 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)
author Christian Brabandt <cb@256bit.org>
date Sun, 29 Oct 2017 16:45:04 +0100
parents e769c912fcd9
children 0c704288ced4
line wrap: on
line diff
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -1715,8 +1715,9 @@ getcmdline(
 		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 @@ getcmdline(
 		    }
 		    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 @@ getcmdline(
 # endif
 			old_botline = curwin->w_botline;
 			update_screen(NOT_VALID);
+			restore_last_search_pattern();
 			redrawcmdline();
 		    }
 		    else
@@ -1934,12 +1938,17 @@ cmdline_changed:
 	    }
 	    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 @@ cmdline_changed:
 		/* 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 @@ cmdline_changed:
 	    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)