vim-patch:8.1.1704: C-R C-W does not work after C-G when using 'incsearch'

Problem:    C-R C-W does not work after C-G when using 'incsearch'.
Solution:   Put cursor at end of the match. (Yasuhiro Matsumoto, closes vim/vim#4664)
69a5b86794
This commit is contained in:
Jan Edmund Lazo 2020-09-13 02:03:03 -04:00
parent 25992df761
commit 8105fc89c4
No known key found for this signature in database
GPG Key ID: 64915E6E9F735B15
2 changed files with 10 additions and 3 deletions

View File

@ -276,6 +276,7 @@ static void init_incsearch_state(incsearch_state_T *s)
// Sets search_first_line and search_last_line to the address range.
static bool do_incsearch_highlighting(int firstc, incsearch_state_T *s,
int *skiplen, int *patlen)
FUNC_ATTR_NONNULL_ALL
{
char_u *cmd;
cmdmod_T save_cmdmod = cmdmod;
@ -1447,6 +1448,7 @@ static int command_line_execute(VimState *state, int key)
static int may_do_command_line_next_incsearch(int firstc, long count,
incsearch_state_T *s,
bool next_match)
FUNC_ATTR_NONNULL_ALL
{
int skiplen, patlen;
@ -1540,6 +1542,7 @@ static int may_do_command_line_next_incsearch(int firstc, long count,
save_viewstate(&s->old_viewstate);
update_screen(NOT_VALID);
redrawcmdline();
curwin->w_cursor = s->match_end;
} else {
vim_beep(BO_ERROR);
}

View File

@ -244,6 +244,10 @@ func Test_search_cmdline2()
" go to previous match (on line 2)
call feedkeys("/the\<C-G>\<C-G>\<C-G>\<C-T>\<C-T>\<C-T>\<cr>", 'tx')
call assert_equal(' 2 these', getline('.'))
1
" go to previous match (on line 2)
call feedkeys("/the\<C-G>\<C-R>\<C-W>\<cr>", 'tx')
call assert_equal('theother', @/)
" Test 2: keep the view,
" after deleting a character from the search cmd
@ -255,7 +259,7 @@ func Test_search_cmdline2()
call assert_equal({'lnum': 10, 'leftcol': 0, 'col': 4, 'topfill': 0, 'topline': 6, 'coladd': 0, 'skipcol': 0, 'curswant': 4}, winsaveview())
" remove all history entries
for i in range(10)
for i in range(11)
call histdel('/')
endfor
@ -489,14 +493,14 @@ func Test_search_cmdline5()
" Do not call test_override("char_avail", 1) so that <C-g> and <C-t> work
" regardless char_avail.
new
call setline(1, [' 1 the first', ' 2 the second', ' 3 the third'])
call setline(1, [' 1 the first', ' 2 the second', ' 3 the third', ''])
set incsearch
1
call feedkeys("/the\<c-g>\<c-g>\<cr>", 'tx')
call assert_equal(' 3 the third', getline('.'))
$
call feedkeys("?the\<c-t>\<c-t>\<c-t>\<cr>", 'tx')
call assert_equal(' 2 the second', getline('.'))
call assert_equal(' 1 the first', getline('.'))
" clean up
set noincsearch
bw!