mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:9.1.0692: Wrong patlen value in ex_substitute() (#30131)
Problem: Wrong patlen value in ex_substitute() (after 9.1.0426).
Solution: Compute patlen after finding end separator.
(zeertzjq)
Add a more explicit test. The test already passes as the only case
where a overlarge patlen value matters was fixed by patch 9.1.0689.
closes: vim/vim#15565
d1c8d2de4b
This commit is contained in:
parent
bb4b6b427c
commit
91ce0c3ddd
@ -3378,12 +3378,12 @@ static int do_sub(exarg_T *eap, const proftime_T timeout, const int cmdpreview_n
|
|||||||
which_pat = RE_LAST; // use last used regexp
|
which_pat = RE_LAST; // use last used regexp
|
||||||
delimiter = (uint8_t)(*cmd++); // remember delimiter character
|
delimiter = (uint8_t)(*cmd++); // remember delimiter character
|
||||||
pat = cmd; // remember start of search pat
|
pat = cmd; // remember start of search pat
|
||||||
patlen = strlen(pat);
|
|
||||||
cmd = skip_regexp_ex(cmd, delimiter, magic_isset(), &eap->arg, NULL, NULL);
|
cmd = skip_regexp_ex(cmd, delimiter, magic_isset(), &eap->arg, NULL, NULL);
|
||||||
if (cmd[0] == delimiter) { // end delimiter found
|
if (cmd[0] == delimiter) { // end delimiter found
|
||||||
*cmd++ = NUL; // replace it with a NUL
|
*cmd++ = NUL; // replace it with a NUL
|
||||||
has_second_delim = true;
|
has_second_delim = true;
|
||||||
}
|
}
|
||||||
|
patlen = strlen(pat);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Small incompatibility: vi sees '\n' as end of the command, but in
|
// Small incompatibility: vi sees '\n' as end of the command, but in
|
||||||
|
@ -1668,6 +1668,37 @@ func Test_search_with_no_last_pat()
|
|||||||
call delete('Xresult')
|
call delete('Xresult')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for using the last substitute pattern without last search pattern.
|
||||||
|
func Test_search_with_last_substitute_pat()
|
||||||
|
let lines =<< trim [SCRIPT]
|
||||||
|
new
|
||||||
|
set shortmess+=S
|
||||||
|
call setline(1, repeat(['foofoo'], 3))
|
||||||
|
%s/foo/bar/
|
||||||
|
call assert_equal(repeat(['barfoo'], 3), getline(1, '$'))
|
||||||
|
|
||||||
|
call cursor(1, 1)
|
||||||
|
call assert_equal("/foo", execute('call feedkeys("/\r", "tx")', '')->trim())
|
||||||
|
call assert_equal([0, 1, 4, 0], getpos('.'))
|
||||||
|
|
||||||
|
if has('rightleft')
|
||||||
|
set rightleft rightleftcmd=search
|
||||||
|
call cursor(1, 1)
|
||||||
|
call assert_equal("oof/", execute('call feedkeys("/\r", "tx")', '')->trim())
|
||||||
|
call assert_equal([0, 1, 4, 0], getpos('.'))
|
||||||
|
endif
|
||||||
|
|
||||||
|
call writefile(v:errors, 'Xresult')
|
||||||
|
qall!
|
||||||
|
[SCRIPT]
|
||||||
|
call writefile(lines, 'Xscript', 'D')
|
||||||
|
|
||||||
|
if RunVim([], [], '--clean -S Xscript')
|
||||||
|
call assert_equal([], readfile('Xresult'))
|
||||||
|
endif
|
||||||
|
call delete('Xresult')
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Test for using tilde (~) atom in search. This should use the last used
|
" Test for using tilde (~) atom in search. This should use the last used
|
||||||
" substitute pattern
|
" substitute pattern
|
||||||
func Test_search_tilde_pat()
|
func Test_search_tilde_pat()
|
||||||
|
Loading…
Reference in New Issue
Block a user