Skip to content

Commit da5116d

Browse files
committed
patch 8.0.0692: CTRL-G with 'incsearch' and ? goes in the wrong direction
Problem: Using CTRL-G with 'incsearch' and ? goes in the wrong direction. (Ramel Eshed) Solution: Adjust search_start. (Christian Brabandt)
1 parent a83fe75 commit da5116d

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

src/ex_getln.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,6 +1708,14 @@ getcmdline(
17081708
search_start = t;
17091709
(void)decl(&search_start);
17101710
}
1711+
else if (c == Ctrl_G && firstc == '?')
1712+
{
1713+
/* move just after the current match, so that
1714+
* when nv_search finishes the cursor will be
1715+
* put back on the match */
1716+
search_start = t;
1717+
(void)incl(&search_start);
1718+
}
17111719
if (LT_POS(t, search_start) && c == Ctrl_G)
17121720
{
17131721
/* wrap around */

src/testdir/test_search.vim

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,3 +322,37 @@ func Test_search_cmdline3()
322322
call test_override("char_avail", 0)
323323
bw!
324324
endfunc
325+
326+
func Test_search_cmdline4()
327+
if !exists('+incsearch')
328+
return
329+
endif
330+
" need to disable char_avail,
331+
" so that expansion of commandline works
332+
call test_override("char_avail", 1)
333+
new
334+
call setline(1, [' 1 the first', ' 2 the second', ' 3 the third'])
335+
set incsearch
336+
$
337+
call feedkeys("?the\<c-g>\<cr>", 'tx')
338+
call assert_equal(' 3 the third', getline('.'))
339+
$
340+
call feedkeys("?the\<c-g>\<c-g>\<cr>", 'tx')
341+
call assert_equal(' 1 the first', getline('.'))
342+
$
343+
call feedkeys("?the\<c-g>\<c-g>\<c-g>\<cr>", 'tx')
344+
call assert_equal(' 2 the second', getline('.'))
345+
$
346+
call feedkeys("?the\<c-t>\<cr>", 'tx')
347+
call assert_equal(' 1 the first', getline('.'))
348+
$
349+
call feedkeys("?the\<c-t>\<c-t>\<cr>", 'tx')
350+
call assert_equal(' 3 the third', getline('.'))
351+
$
352+
call feedkeys("?the\<c-t>\<c-t>\<c-t>\<cr>", 'tx')
353+
call assert_equal(' 2 the second', getline('.'))
354+
" clean up
355+
set noincsearch
356+
call test_override("char_avail", 0)
357+
bw!
358+
endfunc

src/version.c

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

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
692,
767769
/**/
768770
691,
769771
/**/

0 commit comments

Comments
 (0)