mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
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.
This commit is contained in:
@@ -316,8 +316,8 @@ do_incsearch_highlighting(int firstc, incsearch_state_T *is_state,
|
|||||||
ea.line2 = 1;
|
ea.line2 = 1;
|
||||||
ea.cmd = ccline.cmdbuff;
|
ea.cmd = ccline.cmdbuff;
|
||||||
ea.addr_type = ADDR_LINES;
|
ea.addr_type = ADDR_LINES;
|
||||||
parse_cmd_address(&ea, &dummy);
|
|
||||||
curwin->w_cursor = is_state->search_start;
|
curwin->w_cursor = is_state->search_start;
|
||||||
|
parse_cmd_address(&ea, &dummy);
|
||||||
if (ea.addr_count > 0)
|
if (ea.addr_count > 0)
|
||||||
{
|
{
|
||||||
search_first_line = ea.line1;
|
search_first_line = ea.line1;
|
||||||
@@ -401,6 +401,8 @@ may_do_incsearch_highlighting(
|
|||||||
#endif
|
#endif
|
||||||
if (!p_hls)
|
if (!p_hls)
|
||||||
search_flags += SEARCH_KEEP;
|
search_flags += SEARCH_KEEP;
|
||||||
|
if (search_first_line != 0)
|
||||||
|
search_flags += SEARCH_START;
|
||||||
c = ccline.cmdbuff[skiplen + patlen];
|
c = ccline.cmdbuff[skiplen + patlen];
|
||||||
ccline.cmdbuff[skiplen + patlen] = NUL;
|
ccline.cmdbuff[skiplen + patlen] = NUL;
|
||||||
i = do_search(NULL, firstc == ':' ? '/' : firstc,
|
i = do_search(NULL, firstc == ':' ? '/' : firstc,
|
||||||
|
@@ -351,7 +351,7 @@ func Cmdline3_prep()
|
|||||||
set incsearch
|
set incsearch
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Cmdline3_cleanup()
|
func Incsearch_cleanup()
|
||||||
set noincsearch
|
set noincsearch
|
||||||
call test_override("char_avail", 0)
|
call test_override("char_avail", 0)
|
||||||
bw!
|
bw!
|
||||||
@@ -367,7 +367,7 @@ func Test_search_cmdline3()
|
|||||||
call feedkeys("/the\<c-l>\<cr>", 'tx')
|
call feedkeys("/the\<c-l>\<cr>", 'tx')
|
||||||
call assert_equal(' 2 the~e', getline('.'))
|
call assert_equal(' 2 the~e', getline('.'))
|
||||||
|
|
||||||
call Cmdline3_cleanup()
|
call Incsearch_cleanup()
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_search_cmdline3s()
|
func Test_search_cmdline3s()
|
||||||
@@ -385,7 +385,7 @@ func Test_search_cmdline3s()
|
|||||||
call feedkeys(":%substitute/the\<c-l>/xxx\<cr>", 'tx')
|
call feedkeys(":%substitute/the\<c-l>/xxx\<cr>", 'tx')
|
||||||
call assert_equal(' 2 xxxe', getline('.'))
|
call assert_equal(' 2 xxxe', getline('.'))
|
||||||
|
|
||||||
call Cmdline3_cleanup()
|
call Incsearch_cleanup()
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_search_cmdline3g()
|
func Test_search_cmdline3g()
|
||||||
@@ -400,7 +400,7 @@ func Test_search_cmdline3g()
|
|||||||
call feedkeys(":global/the\<c-l>/d\<cr>", 'tx')
|
call feedkeys(":global/the\<c-l>/d\<cr>", 'tx')
|
||||||
call assert_equal(' 3 the theother', getline(2))
|
call assert_equal(' 3 the theother', getline(2))
|
||||||
|
|
||||||
call Cmdline3_cleanup()
|
call Incsearch_cleanup()
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_search_cmdline3v()
|
func Test_search_cmdline3v()
|
||||||
@@ -417,7 +417,7 @@ func Test_search_cmdline3v()
|
|||||||
call assert_equal(1, line('$'))
|
call assert_equal(1, line('$'))
|
||||||
call assert_equal(' 2 the~e', getline(1))
|
call assert_equal(' 2 the~e', getline(1))
|
||||||
|
|
||||||
call Cmdline3_cleanup()
|
call Incsearch_cleanup()
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_search_cmdline4()
|
func Test_search_cmdline4()
|
||||||
@@ -797,6 +797,27 @@ func Test_incsearch_scrolling()
|
|||||||
call delete('Xscript')
|
call delete('Xscript')
|
||||||
endfunc
|
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()
|
func Test_search_undefined_behaviour()
|
||||||
if !has("terminal")
|
if !has("terminal")
|
||||||
return
|
return
|
||||||
|
@@ -794,6 +794,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
275,
|
||||||
/**/
|
/**/
|
||||||
274,
|
274,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user