Skip to content

Commit aed6d0b

Browse files
committed
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)
1 parent 3a118be commit aed6d0b

3 files changed

Lines changed: 36 additions & 4 deletions

File tree

src/edit.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2821,6 +2821,7 @@ set_completion(colnr_T startcol, list_T *list)
28212821
if (ctrl_x_mode != 0)
28222822
ins_compl_prep(' ');
28232823
ins_compl_clear();
2824+
ins_compl_free();
28242825

28252826
compl_direction = FORWARD;
28262827
if (startcol > curwin->w_cursor.col)

src/testdir/test_popup.vim

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ func! ListMonths()
77
if g:setting != ''
88
exe ":set" g:setting
99
endif
10-
let mth=copy(g:months)
10+
let mth = copy(g:months)
1111
let entered = strcharpart(getline('.'),0,col('.'))
1212
if !empty(entered)
13-
let mth=filter(mth, 'v:val=~"^".entered')
13+
let mth = filter(mth, 'v:val=~"^".entered')
1414
endif
1515
call complete(1, mth)
1616
return ''
@@ -468,7 +468,7 @@ endfunc
468468
" auto-wrap text.
469469
func Test_completion_ctrl_e_without_autowrap()
470470
new
471-
let tw_save=&tw
471+
let tw_save = &tw
472472
set tw=78
473473
let li = [
474474
\ '" zzz',
@@ -478,8 +478,37 @@ func Test_completion_ctrl_e_without_autowrap()
478478
call feedkeys("A\<C-X>\<C-N>\<C-E>\<Esc>", "tx")
479479
call assert_equal(li, getline(1, '$'))
480480

481-
let &tw=tw_save
481+
let &tw = tw_save
482482
q!
483483
endfunc
484484

485+
function! DummyCompleteSix()
486+
call complete(1, ['Hello', 'World'])
487+
return ''
488+
endfunction
489+
490+
" complete() correctly clears the list of autocomplete candidates
491+
" See #1411
492+
func Test_completion_clear_candidate_list()
493+
new
494+
%d
495+
" select first entry from the completion popup
496+
call feedkeys("a xxx\<C-N>\<C-R>=DummyCompleteSix()\<CR>", "tx")
497+
call assert_equal('Hello', getline(1))
498+
%d
499+
" select second entry from the completion popup
500+
call feedkeys("a xxx\<C-N>\<C-R>=DummyCompleteSix()\<CR>\<C-N>", "tx")
501+
call assert_equal('World', getline(1))
502+
%d
503+
" select original text
504+
call feedkeys("a xxx\<C-N>\<C-R>=DummyCompleteSix()\<CR>\<C-N>\<C-N>", "tx")
505+
call assert_equal(' xxx', getline(1))
506+
%d
507+
" back at first entry from completion list
508+
call feedkeys("a xxx\<C-N>\<C-R>=DummyCompleteSix()\<CR>\<C-N>\<C-N>\<C-N>", "tx")
509+
call assert_equal('Hello', getline(1))
510+
511+
bw!
512+
endfunc
513+
485514
" vim: shiftwidth=2 sts=2 expandtab

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+
247,
767769
/**/
768770
246,
769771
/**/

0 commit comments

Comments
 (0)