diff --git a/src/ex_docmd.c b/src/ex_docmd.c index b0451a2110..ffb62814a5 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -12228,14 +12228,23 @@ ex_set(exarg_T *eap) (void)do_set(eap->arg, flags); } -#ifdef FEAT_SEARCH_EXTRA +#if defined(FEAT_SEARCH_EXTRA) || defined(PROTO) + void +set_no_hlsearch(int flag) +{ + no_hlsearch = flag; +# ifdef FEAT_EVAL + set_vim_var_nr(VV_HLSEARCH, !no_hlsearch && p_hls); +# endif +} + /* * ":nohlsearch" */ static void ex_nohlsearch(exarg_T *eap UNUSED) { - SET_NO_HLSEARCH(TRUE); + set_no_hlsearch(TRUE); redraw_all_later(SOME_VALID); } diff --git a/src/ex_getln.c b/src/ex_getln.c index cc6ec38f5b..de613f5040 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -237,8 +237,9 @@ getcmdline( int old_topfill; int init_topfill = curwin->w_topfill; # endif - linenr_T old_botline; + linenr_T old_botline, old_empty_rows; linenr_T init_botline = curwin->w_botline; + linenr_T init_empty_rows = curwin->w_empty_rows; int did_incsearch = FALSE; int incsearch_postponed = FALSE; #endif @@ -291,6 +292,7 @@ getcmdline( old_topfill = curwin->w_topfill; # endif old_botline = curwin->w_botline; + old_empty_rows = curwin->w_empty_rows; #endif /* @@ -1075,6 +1077,7 @@ getcmdline( old_topfill = init_topfill; # endif old_botline = init_botline; + old_empty_rows = init_empty_rows; } #endif redrawcmd(); @@ -1812,6 +1815,7 @@ getcmdline( old_topfill = curwin->w_topfill; # endif old_botline = curwin->w_botline; + old_empty_rows = curwin->w_empty_rows; update_screen(NOT_VALID); redrawcmdline(); } @@ -1980,7 +1984,7 @@ cmdline_changed: if (ccline.cmdlen == 0) { i = 0; - SET_NO_HLSEARCH(TRUE); /* turn off previous highlight */ + set_no_hlsearch(TRUE); /* turn off previous highlight */ redraw_all_later(SOME_VALID); } else @@ -2028,6 +2032,7 @@ cmdline_changed: curwin->w_topfill = old_topfill; # endif curwin->w_botline = old_botline; + curwin->w_empty_rows = old_empty_rows; changed_cline_bef_curs(); update_topline(); @@ -2048,7 +2053,7 @@ cmdline_changed: /* Disable 'hlsearch' highlighting if the pattern matches * everything. Avoids a flash when typing "foo\|". */ if (empty_pattern(ccline.cmdbuff)) - SET_NO_HLSEARCH(TRUE); + set_no_hlsearch(TRUE); validate_cursor(); /* May redraw the status line to show the cursor position. */ @@ -2122,6 +2127,7 @@ returncmd: curwin->w_topfill = old_topfill; # endif curwin->w_botline = old_botline; + curwin->w_empty_rows = old_empty_rows; highlight_match = FALSE; validate_cursor(); /* needed for TAB */ redraw_all_later(SOME_VALID); diff --git a/src/option.c b/src/option.c index 1d3bfa35f6..eb237ae9f0 100644 --- a/src/option.c +++ b/src/option.c @@ -8482,7 +8482,7 @@ set_bool_option( /* when 'hlsearch' is set or reset: reset no_hlsearch */ else if ((int *)varp == &p_hls) { - SET_NO_HLSEARCH(FALSE); + set_no_hlsearch(FALSE); } #endif diff --git a/src/proto/ex_docmd.pro b/src/proto/ex_docmd.pro index 0eace6222f..acd6b08ed8 100644 --- a/src/proto/ex_docmd.pro +++ b/src/proto/ex_docmd.pro @@ -66,6 +66,7 @@ void dialog_msg(char_u *buff, char *format, char_u *fname); char_u *get_behave_arg(expand_T *xp, int idx); char_u *get_messages_arg(expand_T *xp, int idx); char_u *get_mapclear_arg(expand_T *xp, int idx); +void set_no_hlsearch(int flag); int get_pressedreturn(void); void set_pressedreturn(int val); /* vim: set ft=c : */ diff --git a/src/screen.c b/src/screen.c index 838f95e60f..d6eba0b616 100644 --- a/src/screen.c +++ b/src/screen.c @@ -7965,7 +7965,7 @@ next_search_hl( { /* don't free regprog in the match list, it's a copy */ vim_regfree(shl->rm.regprog); - SET_NO_HLSEARCH(TRUE); + set_no_hlsearch(TRUE); } shl->rm.regprog = NULL; shl->lnum = 0; diff --git a/src/search.c b/src/search.c index 39da74a43b..52ba87f922 100644 --- a/src/search.c +++ b/src/search.c @@ -297,7 +297,7 @@ save_re_pat(int idx, char_u *pat, int magic) /* If 'hlsearch' set and search pat changed: need redraw. */ if (p_hls) redraw_all_later(SOME_VALID); - SET_NO_HLSEARCH(FALSE); + set_no_hlsearch(FALSE); #endif } } @@ -340,7 +340,7 @@ restore_search_patterns(void) spats[1] = saved_spats[1]; #ifdef FEAT_SEARCH_EXTRA last_idx = saved_last_idx; - SET_NO_HLSEARCH(saved_no_hlsearch); + set_no_hlsearch(saved_no_hlsearch); #endif } } @@ -391,7 +391,7 @@ restore_last_search_pattern(void) set_vv_searchforward(); # endif last_idx = saved_last_idx; - SET_NO_HLSEARCH(saved_no_hlsearch); + set_no_hlsearch(saved_no_hlsearch); } char_u * @@ -1291,7 +1291,7 @@ do_search( if (no_hlsearch && !(options & SEARCH_KEEP)) { redraw_all_later(SOME_VALID); - SET_NO_HLSEARCH(FALSE); + set_no_hlsearch(FALSE); } #endif @@ -5772,9 +5772,7 @@ read_viminfo_search_pattern(vir_T *virp, int force) spats[idx].off.off = off; #ifdef FEAT_SEARCH_EXTRA if (setlast) - { - SET_NO_HLSEARCH(!hlsearch_on); - } + set_no_hlsearch(!hlsearch_on); #endif } } diff --git a/src/tag.c b/src/tag.c index ca1f2f3655..92ed2a7c4c 100644 --- a/src/tag.c +++ b/src/tag.c @@ -3409,9 +3409,7 @@ jumpto_tag( #ifdef FEAT_SEARCH_EXTRA /* restore no_hlsearch when keeping the old search pattern */ if (search_options) - { - SET_NO_HLSEARCH(save_no_hlsearch); - } + set_no_hlsearch(save_no_hlsearch); #endif /* Return OK if jumped to another file (at least we found the file!). */ diff --git a/src/testdir/dumps/Test_incsearch_scrolling_01.dump b/src/testdir/dumps/Test_incsearch_scrolling_01.dump new file mode 100644 index 0000000000..c133d5f519 --- /dev/null +++ b/src/testdir/dumps/Test_incsearch_scrolling_01.dump @@ -0,0 +1,9 @@ +|.+0&#ffffff0@69 +@50| @19 +|.@69 +@50| @19 +@70 +|t+1&&|a|r|g|e+0&&|t| @63 +|@+0#4040ff13&@2| @66 +|/+0#0000000&|t|a|r|g> @64 +@70 diff --git a/src/testdir/test_search.vim b/src/testdir/test_search.vim index 130562fc5e..93a03434c0 100644 --- a/src/testdir/test_search.vim +++ b/src/testdir/test_search.vim @@ -1,6 +1,7 @@ " Test for the search command source shared.vim +source screendump.vim func Test_search_cmdline() if !exists('+incsearch') @@ -690,6 +691,36 @@ func Test_search_cmdline_incsearch_highlight_attr() bwipe! endfunc +func Test_incsearch_scrolling() + if !CanRunVimInTerminal() + return + endif + call assert_equal(0, &scrolloff) + call writefile([ + \ 'let dots = repeat(".", 120)', + \ 'set incsearch cmdheight=2 scrolloff=0', + \ 'call setline(1, [dots, dots, dots, "", "target", dots, dots])', + \ 'normal gg', + \ 'redraw', + \ ], 'Xscript') + let buf = RunVimInTerminal('-S Xscript', {'rows': 9, 'cols': 70}) + " Need to send one key at a time to force a redraw + call term_sendkeys(buf, '/') + sleep 100m + call term_sendkeys(buf, 't') + sleep 100m + call term_sendkeys(buf, 'a') + sleep 100m + call term_sendkeys(buf, 'r') + sleep 100m + call term_sendkeys(buf, 'g') + call VerifyScreenDump(buf, 'Test_incsearch_scrolling_01', {}) + + call term_sendkeys(buf, "\") + call StopVimInTerminal(buf) + call delete('Xscript') +endfunc + func Test_search_undefined_behaviour() if !has("terminal") return diff --git a/src/version.c b/src/version.c index 73a4b9eaca..b00a023068 100644 --- a/src/version.c +++ b/src/version.c @@ -776,6 +776,10 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1768, +/**/ + 1767, /**/ 1766, /**/ diff --git a/src/vim.h b/src/vim.h index 7e3260d693..b0968d8791 100644 --- a/src/vim.h +++ b/src/vim.h @@ -2460,12 +2460,6 @@ typedef enum { /* Character used as separated in autoload function/variable names. */ #define AUTOLOAD_CHAR '#' -#ifdef FEAT_EVAL -# define SET_NO_HLSEARCH(flag) no_hlsearch = (flag); set_vim_var_nr(VV_HLSEARCH, !no_hlsearch && p_hls) -#else -# define SET_NO_HLSEARCH(flag) no_hlsearch = (flag) -#endif - #ifdef FEAT_JOB_CHANNEL # define MAX_OPEN_CHANNELS 10 #else