Skip to content

Commit f8e8c06

Browse files
committed
patch 8.0.1210: CTRL-G and CTRL-T are ignored with typeahead
Problem: When typing a search pattern CTRL-G and CTRL-T are ignored when there is typeahead. Solution: Don't pass SEARCH_PEEK and don't call char_avail(). (haya14busa, closes #2233)
1 parent 53f0c96 commit f8e8c06

3 files changed

Lines changed: 39 additions & 13 deletions

File tree

src/ex_getln.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,20 @@ trigger_cmd_autocmd(int typechar, int evt)
158158
}
159159
#endif
160160

161+
/*
162+
* Abandon the command line.
163+
*/
164+
static void
165+
abandon_cmdline(void)
166+
{
167+
vim_free(ccline.cmdbuff);
168+
ccline.cmdbuff = NULL;
169+
if (msg_scrolled == 0)
170+
compute_cmdrow();
171+
MSG("");
172+
redraw_cmdline = TRUE;
173+
}
174+
161175
/*
162176
* getcmdline() - accept a command line starting with firstc.
163177
*
@@ -1702,11 +1716,8 @@ getcmdline(
17021716
if (p_is && !cmd_silent && (firstc == '/' || firstc == '?'))
17031717
{
17041718
pos_T t;
1705-
int search_flags = SEARCH_KEEP + SEARCH_NOOF
1706-
+ SEARCH_PEEK;
1719+
int search_flags = SEARCH_KEEP + SEARCH_NOOF;
17071720

1708-
if (char_avail())
1709-
continue;
17101721
cursor_off();
17111722
out_flush();
17121723
if (c == Ctrl_G)
@@ -2083,15 +2094,8 @@ getcmdline(
20832094
}
20842095
#endif
20852096

2086-
if (gotesc) /* abandon command line */
2087-
{
2088-
vim_free(ccline.cmdbuff);
2089-
ccline.cmdbuff = NULL;
2090-
if (msg_scrolled == 0)
2091-
compute_cmdrow();
2092-
MSG("");
2093-
redraw_cmdline = TRUE;
2094-
}
2097+
if (gotesc)
2098+
abandon_cmdline();
20952099
}
20962100

20972101
/*

src/testdir/test_search.vim

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,26 @@ func Test_search_cmdline4()
356356
bw!
357357
endfunc
358358

359+
func Test_search_cmdline5()
360+
if !exists('+incsearch')
361+
return
362+
endif
363+
" Do not call test_override("char_avail", 1) so that <C-g> and <C-t> work
364+
" regardless char_avail.
365+
new
366+
call setline(1, [' 1 the first', ' 2 the second', ' 3 the third'])
367+
set incsearch
368+
1
369+
call feedkeys("/the\<c-g>\<c-g>\<cr>", 'tx')
370+
call assert_equal(' 3 the third', getline('.'))
371+
$
372+
call feedkeys("?the\<c-t>\<c-t>\<c-t>\<cr>", 'tx')
373+
call assert_equal(' 2 the second', getline('.'))
374+
" clean up
375+
set noincsearch
376+
bw!
377+
endfunc
378+
359379
" Tests for regexp with various magic settings
360380
func Test_search_regexp()
361381
enew!

src/version.c

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

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
1210,
764766
/**/
765767
1209,
766768
/**/

0 commit comments

Comments
 (0)