]> granicus.if.org Git - vim/commitdiff
patch 8.2.3940: match highlight disappears when doing incsearch for ":s/pat" v8.2.3940
authorBram Moolenaar <Bram@vim.org>
Wed, 29 Dec 2021 19:22:44 +0000 (19:22 +0000)
committerBram Moolenaar <Bram@vim.org>
Wed, 29 Dec 2021 19:22:44 +0000 (19:22 +0000)
Problem:    Match highlight disappears when doing incsearch for ":s/pat".
Solution:   Only use line limit for incsearch highlighting. (closes #9425)

src/match.c
src/testdir/dumps/Test_match_with_incsearch_1.dump [new file with mode: 0644]
src/testdir/dumps/Test_match_with_incsearch_2.dump [new file with mode: 0644]
src/testdir/test_match.vim
src/version.c

index 40f426ec699ded34b3d02c3aec86e6e56542b3b3..3b5c18e4241d9a109e8a017c0422d5852c41951d 100644 (file)
@@ -427,7 +427,7 @@ next_search_hl(
     int                called_emsg_before = called_emsg;
 
     // for :{range}s/pat only highlight inside the range
-    if (lnum < search_first_line || lnum > search_last_line)
+    if ((lnum < search_first_line || lnum > search_last_line) && cur == NULL)
     {
        shl->lnum = 0;
        return;
diff --git a/src/testdir/dumps/Test_match_with_incsearch_1.dump b/src/testdir/dumps/Test_match_with_incsearch_1.dump
new file mode 100644 (file)
index 0000000..8a9d30c
--- /dev/null
@@ -0,0 +1,6 @@
+>0+0&#ffffff0| @73
+|1| @73
+|2+0#ffffff16#e000002| +0#0000000#ffffff0@73
+|3| @73
+|4| @73
+@57|1|,|1| @10|T|o|p| 
diff --git a/src/testdir/dumps/Test_match_with_incsearch_2.dump b/src/testdir/dumps/Test_match_with_incsearch_2.dump
new file mode 100644 (file)
index 0000000..9e9868b
--- /dev/null
@@ -0,0 +1,6 @@
+|0+1&#ffffff0| +0&&@73
+|1| @73
+|2+0#ffffff16#e000002| +0#0000000#ffffff0@73
+|3| @73
+|4| @73
+|:|s|/|0> @70
index 6ca163b363ae13c10b5fb1d9e5ac4efd6f7b87b2..0af45a49a7baab898c72d883d5a6b2299e94bfca 100644 (file)
@@ -366,6 +366,27 @@ func Test_match_in_linebreak()
   call delete('XscriptMatchLinebreak')
 endfunc
 
+func Test_match_with_incsearch()
+  CheckRunVimInTerminal
+
+  let lines =<< trim END
+    set incsearch
+    call setline(1, range(20))
+    call matchaddpos('ErrorMsg', [3])
+  END
+  call writefile(lines, 'XmatchWithIncsearch')
+  let buf = RunVimInTerminal('-S XmatchWithIncsearch', #{rows: 6})
+  call TermWait(buf)
+  call VerifyScreenDump(buf, 'Test_match_with_incsearch_1', {})
+
+  call term_sendkeys(buf, ":s/0")
+  call VerifyScreenDump(buf, 'Test_match_with_incsearch_2', {})
+
+  call term_sendkeys(buf, "\<CR>")
+  call StopVimInTerminal(buf)
+  call delete('XmatchWithIncsearch')
+endfunc
+
 " Test for deleting matches outside of the screen redraw top/bottom lines
 " This should cause a redraw of those lines.
 func Test_matchdelete_redraw()
index 0f0414e92ddb10689d9006815b87c18bf8a7bea9..ee3a29f51476a60cceadb10bbc006ac00c156961 100644 (file)
@@ -749,6 +749,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3940,
 /**/
     3939,
 /**/