patch 8.1.0275: 'incsearch' with :s doesn't start at cursor line
Problem: 'incsearch' with :s doesn't start at cursor line.
Solution: Set cursor before parsing address. (closes #3318)
Also accept a match at the start of the first line.
diff --git a/src/testdir/test_search.vim b/src/testdir/test_search.vim
index 7e8ddbe..ac5b228 100644
--- a/src/testdir/test_search.vim
+++ b/src/testdir/test_search.vim
@@ -351,7 +351,7 @@
set incsearch
endfunc
-func Cmdline3_cleanup()
+func Incsearch_cleanup()
set noincsearch
call test_override("char_avail", 0)
bw!
@@ -367,7 +367,7 @@
call feedkeys("/the\<c-l>\<cr>", 'tx')
call assert_equal(' 2 the~e', getline('.'))
- call Cmdline3_cleanup()
+ call Incsearch_cleanup()
endfunc
func Test_search_cmdline3s()
@@ -385,7 +385,7 @@
call feedkeys(":%substitute/the\<c-l>/xxx\<cr>", 'tx')
call assert_equal(' 2 xxxe', getline('.'))
- call Cmdline3_cleanup()
+ call Incsearch_cleanup()
endfunc
func Test_search_cmdline3g()
@@ -400,7 +400,7 @@
call feedkeys(":global/the\<c-l>/d\<cr>", 'tx')
call assert_equal(' 3 the theother', getline(2))
- call Cmdline3_cleanup()
+ call Incsearch_cleanup()
endfunc
func Test_search_cmdline3v()
@@ -417,7 +417,7 @@
call assert_equal(1, line('$'))
call assert_equal(' 2 the~e', getline(1))
- call Cmdline3_cleanup()
+ call Incsearch_cleanup()
endfunc
func Test_search_cmdline4()
@@ -797,6 +797,27 @@
call delete('Xscript')
endfunc
+func Test_incsearch_substitute()
+ if !exists('+incsearch')
+ return
+ endif
+ call test_override("char_avail", 1)
+ new
+ set incsearch
+ for n in range(1, 10)
+ call setline(n, 'foo ' . n)
+ endfor
+ 4
+ call feedkeys(":.,.+2s/foo\<BS>o\<BS>o/xxx\<cr>", 'tx')
+ call assert_equal('foo 3', getline(3))
+ call assert_equal('xxx 4', getline(4))
+ call assert_equal('xxx 5', getline(5))
+ call assert_equal('xxx 6', getline(6))
+ call assert_equal('foo 7', getline(7))
+
+ call Incsearch_cleanup()
+endfunc
+
func Test_search_undefined_behaviour()
if !has("terminal")
return