diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-01-27 21:48:54 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-01-27 21:48:54 +0100 |
commit | aed6d0b81a14a81433c0f3c2c65cef935100db33 (patch) | |
tree | d15d72557150af0ecd7ecae8e26ba4f181cf9664 | |
parent | 3a118be1501549a7a9b8f52618fd0a967470d0a1 (diff) |
patch 8.0.0247: need to type Ctrl-N twice to select a completionv8.0.0247
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)
-rw-r--r-- | src/edit.c | 1 | ||||
-rw-r--r-- | src/testdir/test_popup.vim | 37 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 36 insertions, 4 deletions
diff --git a/src/edit.c b/src/edit.c index af1d00b85d..47932c916a 100644 --- a/src/edit.c +++ b/src/edit.c @@ -2821,6 +2821,7 @@ set_completion(colnr_T startcol, list_T *list) if (ctrl_x_mode != 0) ins_compl_prep(' '); ins_compl_clear(); + ins_compl_free(); compl_direction = FORWARD; if (startcol > curwin->w_cursor.col) diff --git a/src/testdir/test_popup.vim b/src/testdir/test_popup.vim index 96c8d7e30a..efbb9185d2 100644 --- a/src/testdir/test_popup.vim +++ b/src/testdir/test_popup.vim @@ -7,10 +7,10 @@ func! ListMonths() if g:setting != '' exe ":set" g:setting endif - let mth=copy(g:months) + let mth = copy(g:months) let entered = strcharpart(getline('.'),0,col('.')) if !empty(entered) - let mth=filter(mth, 'v:val=~"^".entered') + let mth = filter(mth, 'v:val=~"^".entered') endif call complete(1, mth) return '' @@ -468,7 +468,7 @@ endfunc " auto-wrap text. func Test_completion_ctrl_e_without_autowrap() new - let tw_save=&tw + let tw_save = &tw set tw=78 let li = [ \ '" zzz', @@ -478,8 +478,37 @@ func Test_completion_ctrl_e_without_autowrap() call feedkeys("A\<C-X>\<C-N>\<C-E>\<Esc>", "tx") call assert_equal(li, getline(1, '$')) - let &tw=tw_save + let &tw = tw_save q! 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 diff --git a/src/version.c b/src/version.c index d3c25e6943..199c37d5bd 100644 --- a/src/version.c +++ b/src/version.c @@ -765,6 +765,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 247, +/**/ 246, /**/ 245, |