Skip to content

Commit 69a5b86

Browse files
committed
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 #4664)
1 parent 6138640 commit 69a5b86

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

src/ex_getln.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,7 @@ may_adjust_incsearch_highlighting(
713713
save_viewstate(&is_state->old_viewstate);
714714
update_screen(NOT_VALID);
715715
redrawcmdline();
716+
curwin->w_cursor = is_state->match_end;
716717
}
717718
else
718719
vim_beep(BO_ERROR);

src/testdir/test_search.vim

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ func Test_search_cmdline2()
240240
" go to previous match (on line 2)
241241
call feedkeys("/the\<C-G>\<C-G>\<C-G>\<C-T>\<C-T>\<C-T>\<cr>", 'tx')
242242
call assert_equal(' 2 these', getline('.'))
243+
1
244+
" go to previous match (on line 2)
245+
call feedkeys("/the\<C-G>\<C-R>\<C-W>\<cr>", 'tx')
246+
call assert_equal('theother', @/)
243247

244248
" Test 2: keep the view,
245249
" after deleting a character from the search cmd
@@ -251,7 +255,7 @@ func Test_search_cmdline2()
251255
call assert_equal({'lnum': 10, 'leftcol': 0, 'col': 4, 'topfill': 0, 'topline': 6, 'coladd': 0, 'skipcol': 0, 'curswant': 4}, winsaveview())
252256

253257
" remove all history entries
254-
for i in range(10)
258+
for i in range(11)
255259
call histdel('/')
256260
endfor
257261

@@ -477,14 +481,14 @@ func Test_search_cmdline5()
477481
" Do not call test_override("char_avail", 1) so that <C-g> and <C-t> work
478482
" regardless char_avail.
479483
new
480-
call setline(1, [' 1 the first', ' 2 the second', ' 3 the third'])
484+
call setline(1, [' 1 the first', ' 2 the second', ' 3 the third', ''])
481485
set incsearch
482486
1
483487
call feedkeys("/the\<c-g>\<c-g>\<cr>", 'tx')
484488
call assert_equal(' 3 the third', getline('.'))
485489
$
486490
call feedkeys("?the\<c-t>\<c-t>\<c-t>\<cr>", 'tx')
487-
call assert_equal(' 2 the second', getline('.'))
491+
call assert_equal(' 1 the first', getline('.'))
488492
" clean up
489493
set noincsearch
490494
bw!

src/version.c

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

778778
static int included_patches[] =
779779
{ /* Add new patch number below this line */
780+
/**/
781+
1704,
780782
/**/
781783
1703,
782784
/**/

0 commit comments

Comments
 (0)