comparison src/testdir/test_popup.vim @ 10714:319bafc99ee8 v8.0.0247

patch 8.0.0247: need to type Ctrl-N twice to select a completion commit https://github.com/vim/vim/commit/aed6d0b81a14a81433c0f3c2c65cef935100db33 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jan 27 21:48:54 2017 +0100 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)
author Christian Brabandt <cb@256bit.org>
date Fri, 27 Jan 2017 22:00:05 +0100
parents 251554157361
children 64ccb8029e06
comparison
equal deleted inserted replaced
10713:3cb3793af176 10714:319bafc99ee8
5 5
6 func! ListMonths() 6 func! ListMonths()
7 if g:setting != '' 7 if g:setting != ''
8 exe ":set" g:setting 8 exe ":set" g:setting
9 endif 9 endif
10 let mth=copy(g:months) 10 let mth = copy(g:months)
11 let entered = strcharpart(getline('.'),0,col('.')) 11 let entered = strcharpart(getline('.'),0,col('.'))
12 if !empty(entered) 12 if !empty(entered)
13 let mth=filter(mth, 'v:val=~"^".entered') 13 let mth = filter(mth, 'v:val=~"^".entered')
14 endif 14 endif
15 call complete(1, mth) 15 call complete(1, mth)
16 return '' 16 return ''
17 endfunc 17 endfunc
18 18
466 466
467 " <C-E> - select original typed text before the completion started without 467 " <C-E> - select original typed text before the completion started without
468 " auto-wrap text. 468 " auto-wrap text.
469 func Test_completion_ctrl_e_without_autowrap() 469 func Test_completion_ctrl_e_without_autowrap()
470 new 470 new
471 let tw_save=&tw 471 let tw_save = &tw
472 set tw=78 472 set tw=78
473 let li = [ 473 let li = [
474 \ '" zzz', 474 \ '" zzz',
475 \ '" zzzyyyyyyyyyyyyyyyyyyy'] 475 \ '" zzzyyyyyyyyyyyyyyyyyyy']
476 call setline(1, li) 476 call setline(1, li)
477 0 477 0
478 call feedkeys("A\<C-X>\<C-N>\<C-E>\<Esc>", "tx") 478 call feedkeys("A\<C-X>\<C-N>\<C-E>\<Esc>", "tx")
479 call assert_equal(li, getline(1, '$')) 479 call assert_equal(li, getline(1, '$'))
480 480
481 let &tw=tw_save 481 let &tw = tw_save
482 q! 482 q!
483 endfunc
484
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!
483 endfunc 512 endfunc
484 513
485 " vim: shiftwidth=2 sts=2 expandtab 514 " vim: shiftwidth=2 sts=2 expandtab