From 68f6abef1697d6879b76b515b1b2f67fa59dad1a Mon Sep 17 00:00:00 2001 From: Aufar Gilbran Date: Wed, 19 Aug 2020 00:48:03 +0800 Subject: vim-patch:8.1.0284: 'cursorline' highlighting wrong with 'incsearch' Problem: 'cursorline' highlighting wrong with 'incsearch'. Solution: Move the cursor back if the match is outside the range. https://github.com/vim/vim/commit/2f6a346a4cd2d5bdd6dc9b3209ebce7b6340221d --- src/nvim/ex_getln.c | 1 + src/nvim/testdir/test_search.vim | 15 +++++++++++++++ 2 files changed, 16 insertions(+) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 2e10fbff91..c3e40c95a8 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -427,6 +427,7 @@ static void may_do_incsearch_highlighting(int firstc, long count, || curwin->w_cursor.lnum > search_last_line) { // match outside of address range i = 0; + curwin->w_cursor = s->search_start; } // if interrupted while searching, behave like it failed diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim index 6708f30f4e..5f421aad3c 100644 --- a/src/nvim/testdir/test_search.vim +++ b/src/nvim/testdir/test_search.vim @@ -614,6 +614,7 @@ func Test_incsearch_substitute_dump() \ 'for n in range(1, 10)', \ ' call setline(n, "foo " . n)', \ 'endfor', + \ 'call setline(11, "bar 11")', \ '3', \ ], 'Xis_subst_script') let buf = RunVimInTerminal('-S Xis_subst_script', {'rows': 9, 'cols': 70}) @@ -665,6 +666,20 @@ func Test_incsearch_substitute_dump() call VerifyScreenDump(buf, 'Test_incsearch_substitute_06', {}) call term_sendkeys(buf, "\") + " Cursorline highlighting at match + call term_sendkeys(buf, ":set cursorline\") + call term_sendkeys(buf, 'G9G') + call term_sendkeys(buf, ':9,11s/bar') + sleep 100m + call VerifyScreenDump(buf, 'Test_incsearch_substitute_07', {}) + call term_sendkeys(buf, "\") + + " Cursorline highlighting at cursor when no match + call term_sendkeys(buf, ':9,10s/bar') + sleep 100m + call VerifyScreenDump(buf, 'Test_incsearch_substitute_08', {}) + call term_sendkeys(buf, "\") + call StopVimInTerminal(buf) call delete('Xis_subst_script') endfunc -- cgit