diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-12-16 16:33:44 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-12-16 16:33:44 +0100 |
commit | 6621605eb97cf5fbc481282fd4d349a76e168f16 (patch) | |
tree | a987db3257da14c08cba740c01682b6ca9446202 /src/ex_getln.c | |
parent | 8b42328cef294a5d6059ee7c452da75b845f6f8c (diff) | |
download | vim-git-6621605eb97cf5fbc481282fd4d349a76e168f16.tar.gz |
patch 8.0.1393: too much highlighting with 'hlsearch' and 'incsearch' setv8.0.1393
Problem: Too much highlighting with 'hlsearch' and 'incsearch' set.
Solution: Do not highlight matches when the pattern matches everything.
Diffstat (limited to 'src/ex_getln.c')
-rw-r--r-- | src/ex_getln.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/ex_getln.c b/src/ex_getln.c index 4202b036e..7c553e42e 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -173,6 +173,22 @@ abandon_cmdline(void) } /* + * Guess that the pattern matches everything. Only finds specific cases, such + * as a trailing \|, which can happen while typing a pattern. + */ + static int +empty_pattern(char_u *p) +{ + int n = STRLEN(p); + + /* remove trailing \v and the like */ + while (n >= 2 && p[n - 2] == '\\' + && vim_strchr((char_u *)"mMvVcCZ", p[n - 1]) != NULL) + n -= 2; + return n == 0 || (n >= 2 && p[n - 2] == '\\' && p[n - 1] == '|'); +} + +/* * getcmdline() - accept a command line starting with firstc. * * firstc == ':' get ":" command line. @@ -2023,6 +2039,11 @@ cmdline_changed: else end_pos = curwin->w_cursor; /* shutup gcc 4 */ + /* Disable 'hlsearch' highlighting if the pattern matches + * everything. Avoids a flash when typing "foo\|". */ + if (empty_pattern(ccline.cmdbuff)) + SET_NO_HLSEARCH(TRUE); + validate_cursor(); /* May redraw the status line to show the cursor position. */ if (p_ru && curwin->w_status_height > 0) |