Mercurial > vim
annotate src/testdir/test_popup.vim @ 9686:8c2553beff0f v7.4.2119
commit https://github.com/vim/vim/commit/1e96d9bf98f9ab84d5af7f98d6a961d91b17364f
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Jul 29 22:15:09 2016 +0200
patch 7.4.2119
Problem: Closures are not supported.
Solution: Capture variables in lambdas from the outer scope. (Yasuhiro
Matsumoto, Ken Takata)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 29 Jul 2016 22:30:08 +0200 |
parents | 5fb484647e12 |
children | 0b0b9864c811 |
rev | line source |
---|---|
9359
35b173e37dc6
commit https://github.com/vim/vim/commit/00672e1d3f59dbff91a18d418b2984be96f89ee5
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Test for completion menu |
35b173e37dc6
commit https://github.com/vim/vim/commit/00672e1d3f59dbff91a18d418b2984be96f89ee5
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
35b173e37dc6
commit https://github.com/vim/vim/commit/00672e1d3f59dbff91a18d418b2984be96f89ee5
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 let g:months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] |
35b173e37dc6
commit https://github.com/vim/vim/commit/00672e1d3f59dbff91a18d418b2984be96f89ee5
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 let g:setting = '' |
35b173e37dc6
commit https://github.com/vim/vim/commit/00672e1d3f59dbff91a18d418b2984be96f89ee5
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 |
35b173e37dc6
commit https://github.com/vim/vim/commit/00672e1d3f59dbff91a18d418b2984be96f89ee5
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 func ListMonths() |
35b173e37dc6
commit https://github.com/vim/vim/commit/00672e1d3f59dbff91a18d418b2984be96f89ee5
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 if g:setting != '' |
35b173e37dc6
commit https://github.com/vim/vim/commit/00672e1d3f59dbff91a18d418b2984be96f89ee5
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 exe ":set" g:setting |
35b173e37dc6
commit https://github.com/vim/vim/commit/00672e1d3f59dbff91a18d418b2984be96f89ee5
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 endif |
35b173e37dc6
commit https://github.com/vim/vim/commit/00672e1d3f59dbff91a18d418b2984be96f89ee5
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 call complete(col('.'), g:months) |
35b173e37dc6
commit https://github.com/vim/vim/commit/00672e1d3f59dbff91a18d418b2984be96f89ee5
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 return '' |
35b173e37dc6
commit https://github.com/vim/vim/commit/00672e1d3f59dbff91a18d418b2984be96f89ee5
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 endfunc |
35b173e37dc6
commit https://github.com/vim/vim/commit/00672e1d3f59dbff91a18d418b2984be96f89ee5
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 |
35b173e37dc6
commit https://github.com/vim/vim/commit/00672e1d3f59dbff91a18d418b2984be96f89ee5
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 func! Test_popup_completion_insertmode() |
9465
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
15 new |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
16 inoremap <F5> <C-R>=ListMonths()<CR> |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
17 |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
18 call feedkeys("a\<f5>\<down>\<enter>\<esc>", 'tx') |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
19 call assert_equal('February', getline(1)) |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
20 %d |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
21 let g:setting = 'noinsertmode' |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
22 call feedkeys("a\<f5>\<down>\<enter>\<esc>", 'tx') |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
23 call assert_equal('February', getline(1)) |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
24 call assert_false(pumvisible()) |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
25 %d |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
26 let g:setting = '' |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
27 call feedkeys("a\<f5>". repeat("\<c-n>",12)."\<enter>\<esc>", 'tx') |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
28 call assert_equal('', getline(1)) |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
29 %d |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
30 call feedkeys("a\<f5>\<c-p>\<enter>\<esc>", 'tx') |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
31 call assert_equal('', getline(1)) |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
32 %d |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
33 call feedkeys("a\<f5>\<c-p>\<c-p>\<enter>\<esc>", 'tx') |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
34 call assert_equal('December', getline(1)) |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
35 |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
36 bwipe! |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
37 iunmap <F5> |
9359
35b173e37dc6
commit https://github.com/vim/vim/commit/00672e1d3f59dbff91a18d418b2984be96f89ee5
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 endfunc |
9465
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
39 |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
40 function! ComplTest() abort |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
41 call complete(1, ['source', 'soundfold']) |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
42 return '' |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
43 endfunction |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
44 |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
45 func Test_noinsert_complete() |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
46 new |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
47 set completeopt+=noinsert |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
48 inoremap <F5> <C-R>=ComplTest()<CR> |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
49 call feedkeys("i\<F5>soun\<CR>\<CR>\<ESC>.", 'tx') |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
50 call assert_equal('soundfold', getline(1)) |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
51 call assert_equal('soundfold', getline(2)) |
9467
5fb484647e12
commit https://github.com/vim/vim/commit/32b808a4bdf35b0dea63c735702a591e5869fecd
Christian Brabandt <cb@256bit.org>
parents:
9465
diff
changeset
|
52 bwipe! |
9465
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
53 |
9467
5fb484647e12
commit https://github.com/vim/vim/commit/32b808a4bdf35b0dea63c735702a591e5869fecd
Christian Brabandt <cb@256bit.org>
parents:
9465
diff
changeset
|
54 new |
5fb484647e12
commit https://github.com/vim/vim/commit/32b808a4bdf35b0dea63c735702a591e5869fecd
Christian Brabandt <cb@256bit.org>
parents:
9465
diff
changeset
|
55 inoremap <F5> <C-R>=Test()<CR> |
5fb484647e12
commit https://github.com/vim/vim/commit/32b808a4bdf35b0dea63c735702a591e5869fecd
Christian Brabandt <cb@256bit.org>
parents:
9465
diff
changeset
|
56 call feedkeys("i\<F5>\<CR>\<ESC>", 'tx') |
5fb484647e12
commit https://github.com/vim/vim/commit/32b808a4bdf35b0dea63c735702a591e5869fecd
Christian Brabandt <cb@256bit.org>
parents:
9465
diff
changeset
|
57 call assert_equal('source', getline(1)) |
9465
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
58 bwipe! |
9467
5fb484647e12
commit https://github.com/vim/vim/commit/32b808a4bdf35b0dea63c735702a591e5869fecd
Christian Brabandt <cb@256bit.org>
parents:
9465
diff
changeset
|
59 |
9465
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
60 set completeopt-=noinsert |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
61 iunmap <F5> |
203792348947
commit https://github.com/vim/vim/commit/67081e50616ae9546621072c5eaaa59bd0a4bed7
Christian Brabandt <cb@256bit.org>
parents:
9359
diff
changeset
|
62 endfunc |
9467
5fb484647e12
commit https://github.com/vim/vim/commit/32b808a4bdf35b0dea63c735702a591e5869fecd
Christian Brabandt <cb@256bit.org>
parents:
9465
diff
changeset
|
63 |
5fb484647e12
commit https://github.com/vim/vim/commit/32b808a4bdf35b0dea63c735702a591e5869fecd
Christian Brabandt <cb@256bit.org>
parents:
9465
diff
changeset
|
64 |
5fb484647e12
commit https://github.com/vim/vim/commit/32b808a4bdf35b0dea63c735702a591e5869fecd
Christian Brabandt <cb@256bit.org>
parents:
9465
diff
changeset
|
65 function! Test() abort |
5fb484647e12
commit https://github.com/vim/vim/commit/32b808a4bdf35b0dea63c735702a591e5869fecd
Christian Brabandt <cb@256bit.org>
parents:
9465
diff
changeset
|
66 call complete(1, ['source', 'soundfold']) |
5fb484647e12
commit https://github.com/vim/vim/commit/32b808a4bdf35b0dea63c735702a591e5869fecd
Christian Brabandt <cb@256bit.org>
parents:
9465
diff
changeset
|
67 return '' |
5fb484647e12
commit https://github.com/vim/vim/commit/32b808a4bdf35b0dea63c735702a591e5869fecd
Christian Brabandt <cb@256bit.org>
parents:
9465
diff
changeset
|
68 endfunction |