Skip to content

Commit 976b847

Browse files
committed
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.
1 parent 21f990e commit 976b847

3 files changed

Lines changed: 31 additions & 6 deletions

File tree

src/ex_getln.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ do_incsearch_highlighting(int firstc, incsearch_state_T *is_state,
316316
ea.line2 = 1;
317317
ea.cmd = ccline.cmdbuff;
318318
ea.addr_type = ADDR_LINES;
319-
parse_cmd_address(&ea, &dummy);
320319
curwin->w_cursor = is_state->search_start;
320+
parse_cmd_address(&ea, &dummy);
321321
if (ea.addr_count > 0)
322322
{
323323
search_first_line = ea.line1;
@@ -401,6 +401,8 @@ may_do_incsearch_highlighting(
401401
#endif
402402
if (!p_hls)
403403
search_flags += SEARCH_KEEP;
404+
if (search_first_line != 0)
405+
search_flags += SEARCH_START;
404406
c = ccline.cmdbuff[skiplen + patlen];
405407
ccline.cmdbuff[skiplen + patlen] = NUL;
406408
i = do_search(NULL, firstc == ':' ? '/' : firstc,

src/testdir/test_search.vim

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ func Cmdline3_prep()
351351
set incsearch
352352
endfunc
353353

354-
func Cmdline3_cleanup()
354+
func Incsearch_cleanup()
355355
set noincsearch
356356
call test_override("char_avail", 0)
357357
bw!
@@ -367,7 +367,7 @@ func Test_search_cmdline3()
367367
call feedkeys("/the\<c-l>\<cr>", 'tx')
368368
call assert_equal(' 2 the~e', getline('.'))
369369

370-
call Cmdline3_cleanup()
370+
call Incsearch_cleanup()
371371
endfunc
372372

373373
func Test_search_cmdline3s()
@@ -385,7 +385,7 @@ func Test_search_cmdline3s()
385385
call feedkeys(":%substitute/the\<c-l>/xxx\<cr>", 'tx')
386386
call assert_equal(' 2 xxxe', getline('.'))
387387

388-
call Cmdline3_cleanup()
388+
call Incsearch_cleanup()
389389
endfunc
390390

391391
func Test_search_cmdline3g()
@@ -400,7 +400,7 @@ func Test_search_cmdline3g()
400400
call feedkeys(":global/the\<c-l>/d\<cr>", 'tx')
401401
call assert_equal(' 3 the theother', getline(2))
402402

403-
call Cmdline3_cleanup()
403+
call Incsearch_cleanup()
404404
endfunc
405405

406406
func Test_search_cmdline3v()
@@ -417,7 +417,7 @@ func Test_search_cmdline3v()
417417
call assert_equal(1, line('$'))
418418
call assert_equal(' 2 the~e', getline(1))
419419

420-
call Cmdline3_cleanup()
420+
call Incsearch_cleanup()
421421
endfunc
422422

423423
func Test_search_cmdline4()
@@ -797,6 +797,27 @@ func Test_incsearch_scrolling()
797797
call delete('Xscript')
798798
endfunc
799799

800+
func Test_incsearch_substitute()
801+
if !exists('+incsearch')
802+
return
803+
endif
804+
call test_override("char_avail", 1)
805+
new
806+
set incsearch
807+
for n in range(1, 10)
808+
call setline(n, 'foo ' . n)
809+
endfor
810+
4
811+
call feedkeys(":.,.+2s/foo\<BS>o\<BS>o/xxx\<cr>", 'tx')
812+
call assert_equal('foo 3', getline(3))
813+
call assert_equal('xxx 4', getline(4))
814+
call assert_equal('xxx 5', getline(5))
815+
call assert_equal('xxx 6', getline(6))
816+
call assert_equal('foo 7', getline(7))
817+
818+
call Incsearch_cleanup()
819+
endfunc
820+
800821
func Test_search_undefined_behaviour()
801822
if !has("terminal")
802823
return

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,8 @@ static char *(features[]) =
794794

795795
static int included_patches[] =
796796
{ /* Add new patch number below this line */
797+
/**/
798+
275,
797799
/**/
798800
274,
799801
/**/

0 commit comments

Comments
 (0)