blob: cefaee26af46b2b4fb7fa7b1e9dc416a64c22be9 [file] [log] [blame]
Bram Moolenaar00672e12016-06-26 18:38:13 +02001" Test for completion menu
2
Bram Moolenaar00672e12016-06-26 18:38:13 +02003let g:months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
4let g:setting = ''
5
6func ListMonths()
7 if g:setting != ''
8 exe ":set" g:setting
9 endif
10 call complete(col('.'), g:months)
11 return ''
12endfunc
13
14func! Test_popup_completion_insertmode()
Bram Moolenaar67081e52016-07-09 21:49:03 +020015 new
16 inoremap <F5> <C-R>=ListMonths()<CR>
17
18 call feedkeys("a\<f5>\<down>\<enter>\<esc>", 'tx')
19 call assert_equal('February', getline(1))
20 %d
21 let g:setting = 'noinsertmode'
22 call feedkeys("a\<f5>\<down>\<enter>\<esc>", 'tx')
23 call assert_equal('February', getline(1))
24 call assert_false(pumvisible())
25 %d
26 let g:setting = ''
27 call feedkeys("a\<f5>". repeat("\<c-n>",12)."\<enter>\<esc>", 'tx')
28 call assert_equal('', getline(1))
29 %d
30 call feedkeys("a\<f5>\<c-p>\<enter>\<esc>", 'tx')
31 call assert_equal('', getline(1))
32 %d
33 call feedkeys("a\<f5>\<c-p>\<c-p>\<enter>\<esc>", 'tx')
34 call assert_equal('December', getline(1))
35
36 bwipe!
37 iunmap <F5>
38endfunc
39
40function! ComplTest() abort
41 call complete(1, ['source', 'soundfold'])
42 return ''
43endfunction
44
45func Test_noinsert_complete()
46 new
47 set completeopt+=noinsert
48 inoremap <F5> <C-R>=ComplTest()<CR>
49 call feedkeys("i\<F5>soun\<CR>\<CR>\<ESC>.", 'tx')
50 call assert_equal('soundfold', getline(1))
51 call assert_equal('soundfold', getline(2))
52
53 bwipe!
54 set completeopt-=noinsert
55 iunmap <F5>
Bram Moolenaar00672e12016-06-26 18:38:13 +020056endfunc