From b59c293c25dce6387c939d536c4d7b0f98d83d9e Mon Sep 17 00:00:00 2001 From: Aufar Gilbran Date: Wed, 19 Aug 2020 00:51:16 +0800 Subject: vim-patch:8.1.0339: wrong highlight when 'incsearch' set and cancelling :s Problem: Wrong highlight when 'incsearch' set and cancelling :s. Solution: Reset search line range. (Hirohito Higashi, Masamichi Abe) https://github.com/vim/vim/commit/f13daa46da85a80dd05704cdde0660c2b2651a5a --- src/nvim/ex_getln.c | 8 +++++++- src/nvim/testdir/test_search.vim | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 49e017fda1..e89d835981 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -604,13 +604,19 @@ static void finish_incsearch_highlighting(int gotesc, incsearch_state_T *s, } restore_viewstate(&s->old_viewstate); highlight_match = false; + + // by default search all lines + search_first_line = 0; + search_last_line = MAXLNUM; + + p_magic = s->magic_save; + validate_cursor(); // needed for TAB if (call_update_screen) { update_screen(SOME_VALID); } else { redraw_all_later(SOME_VALID); } - p_magic = s->magic_save; } } diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim index 479311e934..baa44da665 100644 --- a/src/nvim/testdir/test_search.vim +++ b/src/nvim/testdir/test_search.vim @@ -696,6 +696,15 @@ func Test_incsearch_substitute_dump() call VerifyScreenDump(buf, 'Test_incsearch_substitute_09', {}) call term_sendkeys(buf, "\") + call term_sendkeys(buf, ":set nocursorline\") + + " All matches are highlighted for 'hlsearch' after the incsearch canceled + call term_sendkeys(buf, "1G*") + call term_sendkeys(buf, ":2,5s/foo") + sleep 100m + call term_sendkeys(buf, "\") + call VerifyScreenDump(buf, 'Test_incsearch_substitute_10', {}) + call StopVimInTerminal(buf) call delete('Xis_subst_script') endfunc -- cgit