]> granicus.if.org Git - vim/commitdiff
patch 8.1.0320: too much 'incsearch' highlight for pat matching everything v8.1.0320
authorBram Moolenaar <Bram@vim.org>
Wed, 22 Aug 2018 21:05:44 +0000 (23:05 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 22 Aug 2018 21:05:44 +0000 (23:05 +0200)
Problem:    Too much 'incsearch' highlight for pattern matching everything.
Solution:   Add the skiplen to the command and remove the line range.
            (Christian Brabandt)  Check for empty pattern earlier.

src/ex_getln.c
src/testdir/dumps/Test_incsearch_substitute_09.dump [new file with mode: 0644]
src/testdir/test_search.vim
src/version.c

index b0da5d80eb10bb7433b6425b67c8b1eb48f5896c..1cb3c8b7a1cfab630bca7d5ec1765d47dcb0a35b 100644 (file)
@@ -285,6 +285,7 @@ do_incsearch_highlighting(int firstc, incsearch_state_T *is_state,
     char_u     *dummy;
     exarg_T    ea;
     pos_T      save_cursor;
+    int                use_last_pat;
 
     *skiplen = 0;
     *patlen = ccline.cmdlen;
@@ -361,10 +362,25 @@ do_incsearch_highlighting(int firstc, incsearch_state_T *is_state,
     delim = (delim_optional && vim_isIDc(*p)) ? ' ' : *p++;
     end = skip_regexp(p, delim, p_magic, NULL);
 
-    if (end == p && *end != delim)
+    use_last_pat = end == p && *end == delim;
+
+    if (end == p && !use_last_pat)
        return FALSE;
-    // found a non-empty pattern or //
 
+    // Don't do 'hlsearch' highlighting if the pattern matches everything.
+    if (!use_last_pat)
+    {
+       char c = *end;
+       int  empty;
+
+       *end = NUL;
+       empty = empty_pattern(p);
+       *end = c;
+       if (empty)
+           return FALSE;
+    }
+
+    // found a non-empty pattern or //
     *skiplen = (int)(p - ccline.cmdbuff);
     *patlen = (int)(end - p);
 
@@ -556,17 +572,6 @@ may_do_incsearch_highlighting(
     else
        end_pos = curwin->w_cursor; // shutup gcc 4
 
-    // Disable 'hlsearch' highlighting if the pattern matches everything.
-    // Avoids a flash when typing "foo\|".
-    if (!use_last_pat)
-    {
-       next_char = ccline.cmdbuff[skiplen + patlen];
-       ccline.cmdbuff[skiplen + patlen] = NUL;
-       if (empty_pattern(ccline.cmdbuff))
-           set_no_hlsearch(TRUE);
-       ccline.cmdbuff[skiplen + patlen] = next_char;
-    }
-
     validate_cursor();
     // May redraw the status line to show the cursor position.
     if (p_ru && curwin->w_status_height > 0)
diff --git a/src/testdir/dumps/Test_incsearch_substitute_09.dump b/src/testdir/dumps/Test_incsearch_substitute_09.dump
new file mode 100644 (file)
index 0000000..633e7d8
--- /dev/null
@@ -0,0 +1,9 @@
+|f+0&#ffffff0|o@1| |3| @64
+|f+8&&|o@1| |4| @64
+|f+0&&|o@1| |5| @64
+|f|o@1| |6| @64
+|f|o@1| |7| @64
+|f|o@1| |8| @64
+|f|o@1| |9| @64
+|f|o@1| |1|0| @63
+|:|6|,|7|s|/|\|v> @61
index 9ede26dd3ee2ae3e93d824c2c89dd9b791b82fcd..ba2d21a6e68515ff0af7f3a652ee65b8efdf01ac 100644 (file)
@@ -913,6 +913,14 @@ func Test_incsearch_substitute_dump()
   call VerifyScreenDump(buf, 'Test_incsearch_substitute_08', {})
   call term_sendkeys(buf, "\<Esc>")
 
+  " Only \v handled as empty pattern, does not move cursor
+  call term_sendkeys(buf, '3G4G')
+  call term_sendkeys(buf, ":nohlsearch\<CR>")
+  call term_sendkeys(buf, ':6,7s/\v')
+  sleep 100m
+  call VerifyScreenDump(buf, 'Test_incsearch_substitute_09', {})
+  call term_sendkeys(buf, "\<Esc>")
+
   call StopVimInTerminal(buf)
   call delete('Xis_subst_script')
 endfunc
index 0c3f87c080d3157f98ff2e55b1a492b97341010a..d31f9e0f9a7206e3ad675b347a5b4f30edeb3f2b 100644 (file)
@@ -794,6 +794,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    320,
 /**/
     319,
 /**/