changeset 26823:f1618f8705e4 v8.2.3940

patch 8.2.3940: match highlight disappears when doing incsearch for ":s/pat" Commit: https://github.com/vim/vim/commit/94fb8274ca8c93a10102d41c8bcc848f75cb7334 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Dec 29 19:22:44 2021 +0000 patch 8.2.3940: match highlight disappears when doing incsearch for ":s/pat" Problem: Match highlight disappears when doing incsearch for ":s/pat". Solution: Only use line limit for incsearch highlighting. (closes https://github.com/vim/vim/issues/9425)
author Bram Moolenaar <Bram@vim.org>
date Wed, 29 Dec 2021 20:30:03 +0100
parents 8016871d3afa
children 6dccddda8bbc
files src/match.c src/testdir/dumps/Test_match_with_incsearch_1.dump src/testdir/dumps/Test_match_with_incsearch_2.dump src/testdir/test_match.vim src/version.c
diffstat 5 files changed, 36 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/match.c
+++ b/src/match.c
@@ -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;
new file mode 100644
--- /dev/null
+++ b/src/testdir/dumps/Test_match_with_incsearch_1.dump
@@ -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| 
new file mode 100644
--- /dev/null
+++ b/src/testdir/dumps/Test_match_with_incsearch_2.dump
@@ -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
--- a/src/testdir/test_match.vim
+++ b/src/testdir/test_match.vim
@@ -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()
--- a/src/version.c
+++ b/src/version.c
@@ -750,6 +750,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    3940,
+/**/
     3939,
 /**/
     3938,