diff options
author | Aufar Gilbran <aufargilbran@gmail.com> | 2020-08-19 00:50:58 +0800 |
---|---|---|
committer | Aufar Gilbran <aufargilbran@gmail.com> | 2020-09-11 10:37:52 +0800 |
commit | 4770a2bac52530dcfec64aa61cf29379a5ddec36 (patch) | |
tree | 68315deda5710a289508b898cec23077a74d76d7 | |
parent | 5f5d08a88e3038b8f94d0f5b6619cde76e403448 (diff) | |
download | rneovim-4770a2bac52530dcfec64aa61cf29379a5ddec36.tar.gz rneovim-4770a2bac52530dcfec64aa61cf29379a5ddec36.tar.bz2 rneovim-4770a2bac52530dcfec64aa61cf29379a5ddec36.zip |
vim-patch:8.1.0320: too much 'incsearch' highlight for pat matching everything
Problem: Too much 'incsearch' highlight for pattern matching everything.
Solution: Add the skiplen to the command and remove the line range.
(Christian Brabandt) Check for empty pattern earlier.
https://github.com/vim/vim/commit/8b0d5ce881ac16a36ea00018ba13a58b0fdb7534
-rw-r--r-- | src/nvim/ex_getln.c | 30 | ||||
-rw-r--r-- | src/nvim/testdir/test_search.vim | 8 |
2 files changed, 25 insertions, 13 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 75be441edc..241e8a9a89 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -286,6 +286,7 @@ static bool do_incsearch_highlighting(int firstc, incsearch_state_T *s, char_u *dummy; exarg_T ea; pos_T save_cursor; + bool use_last_pat; *skiplen = 0; *patlen = ccline.cmdlen; @@ -365,11 +366,25 @@ static bool do_incsearch_highlighting(int firstc, incsearch_state_T *s, delim = (delim_optional && vim_isIDc(*p)) ? ' ' : *p++; end = skip_regexp(p, delim, p_magic, NULL); - if (end == p && *end != delim) { + use_last_pat = end == p && *end == delim; + if (end == p && !use_last_pat) { return false; } - // found a non-empty pattern or // + // Don't do 'hlsearch' highlighting if the pattern matches everything. + if (!use_last_pat) { + char_u c = *end; + int empty; + + *end = NUL; + empty = empty_pattern(p); + *end = c; + if (empty) { + return false; + } + } + + // found a non-empty pattern or // *skiplen = (int)(p - ccline.cmdbuff); *patlen = (int)(end - p); @@ -505,17 +520,6 @@ static void may_do_incsearch_highlighting(int firstc, long count, 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. if (p_ru && curwin->w_status_height > 0) { diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim index ef25a3c14d..521ddeaddb 100644 --- a/src/nvim/testdir/test_search.vim +++ b/src/nvim/testdir/test_search.vim @@ -688,6 +688,14 @@ func Test_incsearch_substitute_dump() call VerifyScreenDump(buf, 'Test_incsearch_substitute_08', {}) call term_sendkeys(buf, "\<Esc>") + " Only \v handled as empty pattern, does not move cursor + call term_sendkeys(buf, '3G4G') + call term_sendkeys(buf, ":nohlsearch\<CR>") + call term_sendkeys(buf, ':6,7s/\v') + sleep 100m + call VerifyScreenDump(buf, 'Test_incsearch_substitute_09', {}) + call term_sendkeys(buf, "\<Esc>") + call StopVimInTerminal(buf) call delete('Xis_subst_script') endfunc |