diff options
author | Ömer Sinan Ağacan <omeragacan@gmail.com> | 2018-01-21 16:03:35 +0300 |
---|---|---|
committer | Ömer Sinan Ağacan <omeragacan@gmail.com> | 2018-01-26 18:39:20 +0300 |
commit | 87e03c2b85cef0b31eee5aab5078cd6457dd3c9b (patch) | |
tree | b550efdddcd907121f9297973cfe53c9189bc501 | |
parent | 9bc1410ee1a467a8058a8de585c0e68d64ef8521 (diff) | |
download | rneovim-87e03c2b85cef0b31eee5aab5078cd6457dd3c9b.tar.gz rneovim-87e03c2b85cef0b31eee5aab5078cd6457dd3c9b.tar.bz2 rneovim-87e03c2b85cef0b31eee5aab5078cd6457dd3c9b.zip |
vim-patch:8.0.1393: too much highlighting with 'hlsearch' and 'incsearch' set
Problem: Too much highlighting with 'hlsearch' and 'incsearch' set.
Solution: Do not highlight matches when the pattern matches everything.
https://github.com/vim/vim/commit/6621605eb97cf5fbc481282fd4d349a76e168f16
-rw-r--r-- | src/nvim/ex_getln.c | 21 | ||||
-rw-r--r-- | src/nvim/version.c | 2 |
2 files changed, 22 insertions, 1 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 2178505874..a2f8994403 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -1781,6 +1781,20 @@ static int command_line_not_changed(CommandLineState *s) return command_line_changed(s); } +/// 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] == '|'); +} + static int command_line_changed(CommandLineState *s) { // 'incsearch' highlighting. @@ -1856,6 +1870,13 @@ static int command_line_changed(CommandLineState *s) end_pos = curwin->w_cursor; // shutup gcc 4 } + + // Disable 'hlsearch' highlighting if the pattern matches8.0.1304 + // 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) { diff --git a/src/nvim/version.c b/src/nvim/version.c index ba2912ef29..e627022ea6 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -104,7 +104,7 @@ static const int included_patches[] = { 1396, // 1395, // 1394, - // 1393, + 1393, // 1392, // 1391, // 1390, |