Skip to content

Commit

Permalink
Fix c_Ctrl-G/T doesn't work when char_avail() is true
Browse files Browse the repository at this point in the history
c_Ctrl-G/T should work regardless char_avail() state because it moves
cursor position.

Users might use c_Ctrl-G/T by mapping, :normal or feedkeys().
  • Loading branch information
haya14busa committed Oct 22, 2017
1 parent 67435d9 commit d7b5bd5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/ex_getln.c
Original file line number Diff line number Diff line change
Expand Up @@ -1702,11 +1702,8 @@ getcmdline(
if (p_is && !cmd_silent && (firstc == '/' || firstc == '?'))
{
pos_T t;
int search_flags = SEARCH_KEEP + SEARCH_NOOF
+ SEARCH_PEEK;
int search_flags = SEARCH_KEEP + SEARCH_NOOF;

if (char_avail())
continue;
cursor_off();
out_flush();
if (c == Ctrl_G)
Expand Down
20 changes: 20 additions & 0 deletions src/testdir/test_search.vim
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,26 @@ func Test_search_cmdline4()
bw!
endfunc

func Test_search_cmdline5()
if !exists('+incsearch')
return
endif
" 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'])
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('.'))
" clean up
set noincsearch
bw!
endfunc

" Tests for regexp with various magic settings
func Test_search_regexp()
enew!
Expand Down

0 comments on commit d7b5bd5

Please sign in to comment.