comparison 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
comparison
equal deleted inserted replaced
12719:cd6ab105a71a 12720:37c384802df4
1713 case Ctrl_G: /* next match */ 1713 case Ctrl_G: /* next match */
1714 case Ctrl_T: /* previous match */ 1714 case Ctrl_T: /* previous match */
1715 if (p_is && !cmd_silent && (firstc == '/' || firstc == '?')) 1715 if (p_is && !cmd_silent && (firstc == '/' || firstc == '?'))
1716 { 1716 {
1717 pos_T t; 1717 pos_T t;
1718 int search_flags = SEARCH_KEEP + SEARCH_NOOF; 1718 int search_flags = SEARCH_NOOF;
1719 1719
1720 save_last_search_pattern();
1720 cursor_off(); 1721 cursor_off();
1721 out_flush(); 1722 out_flush();
1722 if (c == Ctrl_G) 1723 if (c == Ctrl_G)
1723 { 1724 {
1724 t = match_end; 1725 t = match_end;
1725 search_flags += SEARCH_COL; 1726 search_flags += SEARCH_COL;
1726 } 1727 }
1727 else 1728 else
1728 t = match_start; 1729 t = match_start;
1730 if (!p_hls)
1731 search_flags += SEARCH_KEEP;
1729 ++emsg_off; 1732 ++emsg_off;
1730 i = searchit(curwin, curbuf, &t, 1733 i = searchit(curwin, curbuf, &t,
1731 c == Ctrl_G ? FORWARD : BACKWARD, 1734 c == Ctrl_G ? FORWARD : BACKWARD,
1732 ccline.cmdbuff, count, search_flags, 1735 ccline.cmdbuff, count, search_flags,
1733 RE_SEARCH, 0, NULL, NULL); 1736 RE_SEARCH, 0, NULL, NULL);
1775 # ifdef FEAT_DIFF 1778 # ifdef FEAT_DIFF
1776 old_topfill = curwin->w_topfill; 1779 old_topfill = curwin->w_topfill;
1777 # endif 1780 # endif
1778 old_botline = curwin->w_botline; 1781 old_botline = curwin->w_botline;
1779 update_screen(NOT_VALID); 1782 update_screen(NOT_VALID);
1783 restore_last_search_pattern();
1780 redrawcmdline(); 1784 redrawcmdline();
1781 } 1785 }
1782 else 1786 else
1783 vim_beep(BO_ERROR); 1787 vim_beep(BO_ERROR);
1784 goto cmdline_not_changed; 1788 goto cmdline_not_changed;
1932 incsearch_postponed = TRUE; 1936 incsearch_postponed = TRUE;
1933 continue; 1937 continue;
1934 } 1938 }
1935 incsearch_postponed = FALSE; 1939 incsearch_postponed = FALSE;
1936 curwin->w_cursor = search_start; /* start at old position */ 1940 curwin->w_cursor = search_start; /* start at old position */
1941 save_last_search_pattern();
1937 1942
1938 /* If there is no command line, don't do anything */ 1943 /* If there is no command line, don't do anything */
1939 if (ccline.cmdlen == 0) 1944 if (ccline.cmdlen == 0)
1945 {
1940 i = 0; 1946 i = 0;
1947 SET_NO_HLSEARCH(TRUE); /* turn off previous highlight */
1948 }
1941 else 1949 else
1942 { 1950 {
1951 int search_flags = SEARCH_OPT + SEARCH_NOOF + SEARCH_PEEK;
1943 cursor_off(); /* so the user knows we're busy */ 1952 cursor_off(); /* so the user knows we're busy */
1944 out_flush(); 1953 out_flush();
1945 ++emsg_off; /* So it doesn't beep if bad expr */ 1954 ++emsg_off; /* So it doesn't beep if bad expr */
1946 #ifdef FEAT_RELTIME 1955 #ifdef FEAT_RELTIME
1947 /* Set the time limit to half a second. */ 1956 /* Set the time limit to half a second. */
1948 profile_setlimit(500L, &tm); 1957 profile_setlimit(500L, &tm);
1949 #endif 1958 #endif
1959 if (!p_hls)
1960 search_flags += SEARCH_KEEP;
1950 i = do_search(NULL, firstc, ccline.cmdbuff, count, 1961 i = do_search(NULL, firstc, ccline.cmdbuff, count,
1951 SEARCH_KEEP + SEARCH_OPT + SEARCH_NOOF + SEARCH_PEEK, 1962 search_flags,
1952 #ifdef FEAT_RELTIME 1963 #ifdef FEAT_RELTIME
1953 &tm, NULL 1964 &tm, NULL
1954 #else 1965 #else
1955 NULL, NULL 1966 NULL, NULL
1956 #endif 1967 #endif
2003 curwin->w_redr_status = TRUE; 2014 curwin->w_redr_status = TRUE;
2004 2015
2005 save_cmdline(&save_ccline); 2016 save_cmdline(&save_ccline);
2006 update_screen(SOME_VALID); 2017 update_screen(SOME_VALID);
2007 restore_cmdline(&save_ccline); 2018 restore_cmdline(&save_ccline);
2019 restore_last_search_pattern();
2008 2020
2009 /* Leave it at the end to make CTRL-R CTRL-W work. */ 2021 /* Leave it at the end to make CTRL-R CTRL-W work. */
2010 if (i != 0) 2022 if (i != 0)
2011 curwin->w_cursor = end_pos; 2023 curwin->w_cursor = end_pos;
2012 2024