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.

6621605eb9
This commit is contained in:
Ömer Sinan Ağacan 2018-01-21 16:03:35 +03:00
parent 9bc1410ee1
commit 87e03c2b85
2 changed files with 22 additions and 1 deletions

View File

@ -1781,6 +1781,20 @@ static int command_line_not_changed(CommandLineState *s)
return command_line_changed(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) static int command_line_changed(CommandLineState *s)
{ {
// 'incsearch' highlighting. // 'incsearch' highlighting.
@ -1856,6 +1870,13 @@ static int command_line_changed(CommandLineState *s)
end_pos = curwin->w_cursor; // shutup gcc 4 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(); validate_cursor();
// May redraw the status line to show the cursor position. // May redraw the status line to show the cursor position.
if (p_ru && curwin->w_status_height > 0) { if (p_ru && curwin->w_status_height > 0) {

View File

@ -104,7 +104,7 @@ static const int included_patches[] = {
1396, 1396,
// 1395, // 1395,
// 1394, // 1394,
// 1393, 1393,
// 1392, // 1392,
// 1391, // 1391,
// 1390, // 1390,