diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-08-22 23:05:44 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-08-22 23:05:44 +0200 |
commit | 8b0d5ce881ac16a36ea00018ba13a58b0fdb7534 (patch) | |
tree | ee2cdc079c9394902d23053aa76d117c11544b07 /src/ex_getln.c | |
parent | 8e7218c45941c9f6263348e8eadf6075d0671832 (diff) |
patch 8.1.0320: too much 'incsearch' highlight for pat matching everythingv8.1.0320
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.
Diffstat (limited to 'src/ex_getln.c')
-rw-r--r-- | src/ex_getln.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/ex_getln.c b/src/ex_getln.c index b0da5d80eb..1cb3c8b7a1 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -285,6 +285,7 @@ do_incsearch_highlighting(int firstc, incsearch_state_T *is_state, char_u *dummy; exarg_T ea; pos_T save_cursor; + int use_last_pat; *skiplen = 0; *patlen = ccline.cmdlen; @@ -361,10 +362,25 @@ do_incsearch_highlighting(int firstc, incsearch_state_T *is_state, 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 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); @@ -556,17 +572,6 @@ may_do_incsearch_highlighting( 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. if (p_ru && curwin->w_status_height > 0) |