aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_getln.c5
-rw-r--r--src/nvim/testdir/test_search.vim32
2 files changed, 31 insertions, 6 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 6023b8d26b..54be8dd590 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -316,8 +316,8 @@ static bool do_incsearch_highlighting(int firstc, incsearch_state_T *s,
ea.line2 = 1;
ea.cmd = ccline.cmdbuff;
ea.addr_type = ADDR_LINES;
- parse_cmd_address(&ea, &dummy);
curwin->w_cursor = s->search_start;
+ parse_cmd_address(&ea, &dummy);
if (ea.addr_count > 0) {
search_first_line = ea.line1;
search_last_line = ea.line2;
@@ -385,6 +385,9 @@ static void may_do_incsearch_highlighting(int firstc, long count,
if (!p_hls) {
search_flags += SEARCH_KEEP;
}
+ if (search_first_line != 0) {
+ search_flags += SEARCH_START;
+ }
c = ccline.cmdbuff[skiplen + patlen];
ccline.cmdbuff[skiplen + patlen] = NUL;
memset(&sia, 0, sizeof(sia));
diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim
index 7348c8c4e2..333f5807fd 100644
--- a/src/nvim/testdir/test_search.vim
+++ b/src/nvim/testdir/test_search.vim
@@ -356,7 +356,7 @@ func Cmdline3_prep()
set incsearch
endfunc
-func Cmdline3_cleanup()
+func Incsearch_cleanup()
throw 'skipped: Nvim does not support test_override()'
set noincsearch
call test_override("char_avail", 0)
@@ -374,7 +374,7 @@ func Test_search_cmdline3()
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()
@@ -393,7 +393,7 @@ func Test_search_cmdline3s()
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()
@@ -409,7 +409,7 @@ func Test_search_cmdline3g()
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()
@@ -427,7 +427,7 @@ func Test_search_cmdline3v()
call assert_equal(1, line('$'))
call assert_equal(' 2 the~e', getline(1))
- call Cmdline3_cleanup()
+ call Incsearch_cleanup()
endfunc
func Test_search_cmdline4()
@@ -682,6 +682,28 @@ func Test_incsearch_scrolling()
call delete('Xscript')
endfunc
+func Test_incsearch_substitute()
+ throw 'skipped: Nvim does not support test_override()'
+ 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