0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.0.0247: need to type Ctrl-N twice to select a completion

Problem:    Under some circumstances, one needs to type Ctrl-N or Ctrl-P twice
            to have a menu entry selected. (Lifepillar)
Solution:   call ins_compl_free(). (Christian Brabandt, closes #1411)
This commit is contained in:
Bram Moolenaar
2017-01-27 21:48:54 +01:00
parent 3a118be150
commit aed6d0b81a
3 changed files with 36 additions and 4 deletions

View File

@@ -2821,6 +2821,7 @@ set_completion(colnr_T startcol, list_T *list)
if (ctrl_x_mode != 0) if (ctrl_x_mode != 0)
ins_compl_prep(' '); ins_compl_prep(' ');
ins_compl_clear(); ins_compl_clear();
ins_compl_free();
compl_direction = FORWARD; compl_direction = FORWARD;
if (startcol > curwin->w_cursor.col) if (startcol > curwin->w_cursor.col)

View File

@@ -482,4 +482,33 @@ func Test_completion_ctrl_e_without_autowrap()
q! q!
endfunc endfunc
function! DummyCompleteSix()
call complete(1, ['Hello', 'World'])
return ''
endfunction
" complete() correctly clears the list of autocomplete candidates
" See #1411
func Test_completion_clear_candidate_list()
new
%d
" select first entry from the completion popup
call feedkeys("a xxx\<C-N>\<C-R>=DummyCompleteSix()\<CR>", "tx")
call assert_equal('Hello', getline(1))
%d
" select second entry from the completion popup
call feedkeys("a xxx\<C-N>\<C-R>=DummyCompleteSix()\<CR>\<C-N>", "tx")
call assert_equal('World', getline(1))
%d
" select original text
call feedkeys("a xxx\<C-N>\<C-R>=DummyCompleteSix()\<CR>\<C-N>\<C-N>", "tx")
call assert_equal(' xxx', getline(1))
%d
" back at first entry from completion list
call feedkeys("a xxx\<C-N>\<C-R>=DummyCompleteSix()\<CR>\<C-N>\<C-N>\<C-N>", "tx")
call assert_equal('Hello', getline(1))
bw!
endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab

View File

@@ -764,6 +764,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
247,
/**/ /**/
246, 246,
/**/ /**/