aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAufar Gilbran <aufargilbran@gmail.com>2020-08-19 00:51:08 +0800
committerAufar Gilbran <aufargilbran@gmail.com>2020-09-11 10:37:52 +0800
commitf2743cfb6555ad0c917a59539a97f74737479ef1 (patch)
tree18b08a50af853d9c90e9f53797228ddd3b323ce3 /src
parent4770a2bac52530dcfec64aa61cf29379a5ddec36 (diff)
downloadrneovim-f2743cfb6555ad0c917a59539a97f74737479ef1.tar.gz
rneovim-f2743cfb6555ad0c917a59539a97f74737479ef1.tar.bz2
rneovim-f2743cfb6555ad0c917a59539a97f74737479ef1.zip
vim-patch:8.1.0321: 'incsearch' regression: /\v highlights everything
Problem: 'incsearch' regression: /\v highlights everything. Solution: Put back the empty_pattern() check. https://github.com/vim/vim/commit/4edfe2d2a2d70ea66a7f73e9b923c2d1f6246a57
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_getln.c11
-rw-r--r--src/nvim/testdir/test_search.vim37
2 files changed, 47 insertions, 1 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 241e8a9a89..49e017fda1 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -519,6 +519,17 @@ static void may_do_incsearch_highlighting(int firstc, long count,
} else {
end_pos = curwin->w_cursor; // shutup gcc 4
}
+ //
+ // Disable 'hlsearch' highlighting if the pattern matches
+ // everything. Avoids a flash when typing "foo\|".
+ if (!use_last_pat) {
+ next_char = ccline.cmdbuff[skiplen + patlen];
+ ccline.cmdbuff[skiplen + patlen] = NUL;
+ if (empty_pattern(ccline.cmdbuff)) {
+ set_no_hlsearch(true);
+ }
+ ccline.cmdbuff[skiplen + patlen] = next_char;
+ }
validate_cursor();
// May redraw the status line to show the cursor position.
diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim
index 521ddeaddb..479311e934 100644
--- a/src/nvim/testdir/test_search.vim
+++ b/src/nvim/testdir/test_search.vim
@@ -701,7 +701,7 @@ func Test_incsearch_substitute_dump()
endfunc
" Similar to Test_incsearch_substitute_dump() for :sort
-func Test_incsearch_ssort_dump()
+func Test_incsearch_sort_dump()
if !exists('+incsearch')
return
endif
@@ -828,6 +828,41 @@ func Test_incsearch_scrolling()
call delete('Xscript')
endfunc
+func Test_incsearch_search_dump()
+ if !exists('+incsearch')
+ return
+ endif
+ if !CanRunVimInTerminal()
+ return
+ endif
+ call writefile([
+ \ 'set incsearch hlsearch scrolloff=0',
+ \ 'for n in range(1, 8)',
+ \ ' call setline(n, "foo " . n)',
+ \ 'endfor',
+ \ '3',
+ \ ], 'Xis_search_script')
+ let buf = RunVimInTerminal('-S Xis_search_script', {'rows': 9, 'cols': 70})
+ " Give Vim a chance to redraw to get rid of the spaces in line 2 caused by
+ " the 'ambiwidth' check.
+ sleep 100m
+
+ " Need to send one key at a time to force a redraw.
+ call term_sendkeys(buf, '/fo')
+ sleep 100m
+ call VerifyScreenDump(buf, 'Test_incsearch_search_01', {})
+ call term_sendkeys(buf, "\<Esc>")
+ sleep 100m
+
+ call term_sendkeys(buf, '/\v')
+ sleep 100m
+ call VerifyScreenDump(buf, 'Test_incsearch_search_02', {})
+ call term_sendkeys(buf, "\<Esc>")
+
+ call StopVimInTerminal(buf)
+ call delete('Xis_search_script')
+endfunc
+
func Test_incsearch_substitute()
throw 'skipped: Nvim does not support test_override()'
if !exists('+incsearch')