Skip to content

Commit 6621605

Browse files
committed
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.
1 parent 8b42328 commit 6621605

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

src/ex_getln.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,22 @@ abandon_cmdline(void)
172172
redraw_cmdline = TRUE;
173173
}
174174

175+
/*
176+
* Guess that the pattern matches everything. Only finds specific cases, such
177+
* as a trailing \|, which can happen while typing a pattern.
178+
*/
179+
static int
180+
empty_pattern(char_u *p)
181+
{
182+
int n = STRLEN(p);
183+
184+
/* remove trailing \v and the like */
185+
while (n >= 2 && p[n - 2] == '\\'
186+
&& vim_strchr((char_u *)"mMvVcCZ", p[n - 1]) != NULL)
187+
n -= 2;
188+
return n == 0 || (n >= 2 && p[n - 2] == '\\' && p[n - 1] == '|');
189+
}
190+
175191
/*
176192
* getcmdline() - accept a command line starting with firstc.
177193
*
@@ -2023,6 +2039,11 @@ getcmdline(
20232039
else
20242040
end_pos = curwin->w_cursor; /* shutup gcc 4 */
20252041

2042+
/* Disable 'hlsearch' highlighting if the pattern matches
2043+
* everything. Avoids a flash when typing "foo\|". */
2044+
if (empty_pattern(ccline.cmdbuff))
2045+
SET_NO_HLSEARCH(TRUE);
2046+
20262047
validate_cursor();
20272048
/* May redraw the status line to show the cursor position. */
20282049
if (p_ru && curwin->w_status_height > 0)

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,8 @@ static char *(features[]) =
771771

772772
static int included_patches[] =
773773
{ /* Add new patch number below this line */
774+
/**/
775+
1393,
774776
/**/
775777
1392,
776778
/**/

0 commit comments

Comments
 (0)