mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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:
parent
9bc1410ee1
commit
87e03c2b85
@ -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) {
|
||||
|
@ -104,7 +104,7 @@ static const int included_patches[] = {
|
||||
1396,
|
||||
// 1395,
|
||||
// 1394,
|
||||
// 1393,
|
||||
1393,
|
||||
// 1392,
|
||||
// 1391,
|
||||
// 1390,
|
||||
|
Loading…
Reference in New Issue
Block a user