]> granicus.if.org Git - vim/commitdiff
patch 8.0.1393: too much highlighting with 'hlsearch' and 'incsearch' set v8.0.1393
authorBram Moolenaar <Bram@vim.org>
Sat, 16 Dec 2017 15:33:44 +0000 (16:33 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 16 Dec 2017 15:33:44 +0000 (16:33 +0100)
Problem:    Too much highlighting with 'hlsearch' and 'incsearch' set.
Solution:   Do not highlight matches when the pattern matches everything.

src/ex_getln.c
src/version.c

index 4202b036e40d5df9e6f79e60b887191009f59601..7c553e42e24cc264a71b34ed46156dd62d7b27e9 100644 (file)
@@ -172,6 +172,22 @@ abandon_cmdline(void)
     redraw_cmdline = TRUE;
 }
 
+/*
+ * 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.
  *
@@ -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)
index ab1f81627428ece33cf4274c44080ffa5e316a94..4b18f63ad28f313bff2cf24971a54a87cc140ef9 100644 (file)
@@ -771,6 +771,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1393,
 /**/
     1392,
 /**/