annotate src/testdir/test_ins_complete.vim @ 23770:385d33dfb7df v8.2.2426

patch 8.2.2426: allowing 'completefunc' to switch windows causes trouble Commit: https://github.com/vim/vim/commit/28976e2accf11591c60e8a658a9e03544f0408b2 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jan 29 21:07:07 2021 +0100 patch 8.2.2426: allowing 'completefunc' to switch windows causes trouble Problem: Allowing 'completefunc' to switch windows causes trouble. Solution: use "textwinlock" instead of "textlock".
author Bram Moolenaar <Bram@vim.org>
date Fri, 29 Jan 2021 21:15:04 +0100
parents 704fdd4d0949
children f5225486d3de
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 20285
diff changeset
1 " Test for insert completion
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 20285
diff changeset
2
18892
fb2d26bc8ca1 patch 8.2.0007: popup menu positioned wrong with folding in two tabs
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
3 source screendump.vim
17588
1348696d07cd patch 8.1.1791: 'completeslash' also applies to globpath()
Bram Moolenaar <Bram@vim.org>
parents: 17553
diff changeset
4 source check.vim
12686
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 " Test for insert expansion
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 func Test_ins_complete()
12692
03a6aeea2096 patch 8.0.1224: still interference between test functions
Christian Brabandt <cb@256bit.org>
parents: 12686
diff changeset
8 edit test_ins_complete.vim
12788
cb9b2774f21f patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12728
diff changeset
9 " The files in the current directory interferes with the files
cb9b2774f21f patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12728
diff changeset
10 " used by this test. So use a separate directory for the test.
cb9b2774f21f patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12728
diff changeset
11 call mkdir('Xdir')
cb9b2774f21f patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12728
diff changeset
12 cd Xdir
cb9b2774f21f patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12728
diff changeset
13
12686
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 set ff=unix
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 call writefile(["test11\t36Gepeto\t/Tag/",
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 \ "asd\ttest11file\t36G",
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 \ "Makefile\tto\trun"], 'Xtestfile')
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 call writefile(['', 'start of testfile',
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 \ 'ru',
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 \ 'run1',
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 \ 'run2',
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 \ 'STARTTEST',
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 \ 'ENDTEST',
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 \ 'end of testfile'], 'Xtestdata')
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 set ff&
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 enew!
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 edit Xtestdata
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 new
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 call append(0, ['#include "Xtestfile"', ''])
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 call cursor(2, 1)
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 set cot=
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 set cpt=.,w
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 " add-expands (word from next line) from other window
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 exe "normal iru\<C-N>\<C-N>\<C-X>\<C-N>\<Esc>\<C-A>"
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 call assert_equal('run1 run3', getline('.'))
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 " add-expands (current buffer first)
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 exe "normal o\<C-P>\<C-X>\<C-N>"
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 call assert_equal('run3 run3', getline('.'))
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 " Local expansion, ends in an empty line (unless it becomes a global
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 " expansion)
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 exe "normal o\<C-X>\<C-P>\<C-P>\<C-P>\<C-P>\<C-P>"
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 call assert_equal('', getline('.'))
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 " starts Local and switches to global add-expansion
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 exe "normal o\<C-X>\<C-P>\<C-P>\<C-X>\<C-X>\<C-N>\<C-X>\<C-N>\<C-N>"
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 call assert_equal('run1 run2', getline('.'))
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 set cpt=.,w,i
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 " i-add-expands and switches to local
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 exe "normal OM\<C-N>\<C-X>\<C-N>\<C-X>\<C-N>\<C-X>\<C-X>\<C-X>\<C-P>"
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 call assert_equal("Makefile\tto\trun3", getline('.'))
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 " add-expands lines (it would end in an empty line if it didn't ignored
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 " itself)
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 exe "normal o\<C-X>\<C-L>\<C-X>\<C-L>\<C-P>\<C-P>"
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 call assert_equal("Makefile\tto\trun3", getline('.'))
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 call assert_equal("Makefile\tto\trun3", getline(line('.') - 1))
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 set cpt=kXtestfile
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 " checks k-expansion, and file expansion (use Xtest11 instead of test11,
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 " because TEST11.OUT may match first on DOS)
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 write Xtest11.one
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 write Xtest11.two
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 exe "normal o\<C-N>\<Esc>IX\<Esc>A\<C-X>\<C-F>\<C-N>"
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 call assert_equal('Xtest11.two', getline('.'))
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67 " use CTRL-X CTRL-F to complete Xtest11.one, remove it and then use CTRL-X
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 " CTRL-F again to verify this doesn't cause trouble.
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 exe "normal oXt\<C-X>\<C-F>\<BS>\<BS>\<BS>\<BS>\<BS>\<BS>\<BS>\<BS>\<C-X>\<C-F>"
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 call assert_equal('Xtest11.one', getline('.'))
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 normal ddk
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 set cpt=w
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 " checks make_cyclic in other window
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75 exe "normal oST\<C-N>\<C-P>\<C-P>\<C-P>\<C-P>"
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 call assert_equal('STARTTEST', getline('.'))
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78 set cpt=u nohid
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 " checks unloaded buffer expansion
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 only
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 exe "normal oEN\<C-N>"
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82 call assert_equal('ENDTEST', getline('.'))
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 " checks adding mode abortion
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 exe "normal ounl\<C-N>\<C-X>\<C-X>\<C-P>"
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 call assert_equal('unless', getline('.'))
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 set cpt=t,d def=^\\k* tags=Xtestfile notagbsearch
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 " tag expansion, define add-expansion interrupted
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89 exe "normal o\<C-X>\<C-]>\<C-X>\<C-D>\<C-X>\<C-D>\<C-X>\<C-X>\<C-D>\<C-X>\<C-D>\<C-X>\<C-D>\<C-X>\<C-D>"
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
90 call assert_equal('test11file 36Gepeto /Tag/ asd', getline('.'))
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
91 " t-expansion
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
92 exe "normal oa\<C-N>\<Esc>"
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
93 call assert_equal('asd', getline('.'))
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
94
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
95 %bw!
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
96 call delete('Xtestfile')
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
97 call delete('Xtest11.one')
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
98 call delete('Xtest11.two')
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
99 call delete('Xtestdata')
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
100 set cpt& cot& def& tags& tagbsearch& hidden&
12788
cb9b2774f21f patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12728
diff changeset
101 cd ..
cb9b2774f21f patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12728
diff changeset
102 call delete('Xdir', 'rf')
12686
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
103 endfunc
12728
9c1659761fc3 patch 8.0.1242: function argument with only dash is seen as number zero
Christian Brabandt <cb@256bit.org>
parents: 12692
diff changeset
104
9c1659761fc3 patch 8.0.1242: function argument with only dash is seen as number zero
Christian Brabandt <cb@256bit.org>
parents: 12692
diff changeset
105 func Test_omni_dash()
9c1659761fc3 patch 8.0.1242: function argument with only dash is seen as number zero
Christian Brabandt <cb@256bit.org>
parents: 12692
diff changeset
106 func Omni(findstart, base)
9c1659761fc3 patch 8.0.1242: function argument with only dash is seen as number zero
Christian Brabandt <cb@256bit.org>
parents: 12692
diff changeset
107 if a:findstart
9c1659761fc3 patch 8.0.1242: function argument with only dash is seen as number zero
Christian Brabandt <cb@256bit.org>
parents: 12692
diff changeset
108 return 5
9c1659761fc3 patch 8.0.1242: function argument with only dash is seen as number zero
Christian Brabandt <cb@256bit.org>
parents: 12692
diff changeset
109 else
9c1659761fc3 patch 8.0.1242: function argument with only dash is seen as number zero
Christian Brabandt <cb@256bit.org>
parents: 12692
diff changeset
110 echom a:base
9c1659761fc3 patch 8.0.1242: function argument with only dash is seen as number zero
Christian Brabandt <cb@256bit.org>
parents: 12692
diff changeset
111 return ['-help', '-v']
9c1659761fc3 patch 8.0.1242: function argument with only dash is seen as number zero
Christian Brabandt <cb@256bit.org>
parents: 12692
diff changeset
112 endif
9c1659761fc3 patch 8.0.1242: function argument with only dash is seen as number zero
Christian Brabandt <cb@256bit.org>
parents: 12692
diff changeset
113 endfunc
9c1659761fc3 patch 8.0.1242: function argument with only dash is seen as number zero
Christian Brabandt <cb@256bit.org>
parents: 12692
diff changeset
114 set omnifunc=Omni
9c1659761fc3 patch 8.0.1242: function argument with only dash is seen as number zero
Christian Brabandt <cb@256bit.org>
parents: 12692
diff changeset
115 new
9c1659761fc3 patch 8.0.1242: function argument with only dash is seen as number zero
Christian Brabandt <cb@256bit.org>
parents: 12692
diff changeset
116 exe "normal Gofind -\<C-x>\<C-o>"
23169
5e6855ebc4ea patch 8.2.2130: Insert mode completion messages end up in message history
Bram Moolenaar <Bram@vim.org>
parents: 22717
diff changeset
117 call assert_equal("find -help", getline('$'))
12728
9c1659761fc3 patch 8.0.1242: function argument with only dash is seen as number zero
Christian Brabandt <cb@256bit.org>
parents: 12692
diff changeset
118
9c1659761fc3 patch 8.0.1242: function argument with only dash is seen as number zero
Christian Brabandt <cb@256bit.org>
parents: 12692
diff changeset
119 bwipe!
9c1659761fc3 patch 8.0.1242: function argument with only dash is seen as number zero
Christian Brabandt <cb@256bit.org>
parents: 12692
diff changeset
120 delfunc Omni
9c1659761fc3 patch 8.0.1242: function argument with only dash is seen as number zero
Christian Brabandt <cb@256bit.org>
parents: 12692
diff changeset
121 set omnifunc=
9c1659761fc3 patch 8.0.1242: function argument with only dash is seen as number zero
Christian Brabandt <cb@256bit.org>
parents: 12692
diff changeset
122 endfunc
13215
ae5f855a64be patch 8.0.1482: using feedkeys() does not work to test completion
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
123
14071
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
124 func Test_completefunc_args()
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
125 let s:args = []
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
126 func! CompleteFunc(findstart, base)
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
127 let s:args += [[a:findstart, empty(a:base)]]
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
128 endfunc
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
129 new
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
130
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
131 set completefunc=CompleteFunc
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
132 call feedkeys("i\<C-X>\<C-U>\<Esc>", 'x')
14075
320956bddcef patch 8.1.0055: complete test has wrong order of arguments
Christian Brabandt <cb@256bit.org>
parents: 14071
diff changeset
133 call assert_equal([1, 1], s:args[0])
320956bddcef patch 8.1.0055: complete test has wrong order of arguments
Christian Brabandt <cb@256bit.org>
parents: 14071
diff changeset
134 call assert_equal(0, s:args[1][0])
14071
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
135 set completefunc=
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
136
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
137 let s:args = []
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
138 set omnifunc=CompleteFunc
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
139 call feedkeys("i\<C-X>\<C-O>\<Esc>", 'x')
14075
320956bddcef patch 8.1.0055: complete test has wrong order of arguments
Christian Brabandt <cb@256bit.org>
parents: 14071
diff changeset
140 call assert_equal([1, 1], s:args[0])
320956bddcef patch 8.1.0055: complete test has wrong order of arguments
Christian Brabandt <cb@256bit.org>
parents: 14071
diff changeset
141 call assert_equal(0, s:args[1][0])
14071
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
142 set omnifunc=
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
143
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
144 bwipe!
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
145 unlet s:args
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
146 delfunc CompleteFunc
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
147 endfunc
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
148
15416
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
149 func s:CompleteDone_CompleteFuncNone( findstart, base )
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
150 if a:findstart
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
151 return 0
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
152 endif
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
153
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
154 return v:none
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
155 endfunc
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
156
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 14489
diff changeset
157 func s:CompleteDone_CompleteFuncDict( findstart, base )
13238
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
158 if a:findstart
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
159 return 0
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
160 endif
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
161
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
162 return {
19047
a3fce2763e83 patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents: 18900
diff changeset
163 \ 'words': [
a3fce2763e83 patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents: 18900
diff changeset
164 \ {
a3fce2763e83 patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents: 18900
diff changeset
165 \ 'word': 'aword',
a3fce2763e83 patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents: 18900
diff changeset
166 \ 'abbr': 'wrd',
a3fce2763e83 patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents: 18900
diff changeset
167 \ 'menu': 'extra text',
a3fce2763e83 patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents: 18900
diff changeset
168 \ 'info': 'words are cool',
a3fce2763e83 patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents: 18900
diff changeset
169 \ 'kind': 'W',
a3fce2763e83 patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents: 18900
diff changeset
170 \ 'user_data': 'test'
a3fce2763e83 patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents: 18900
diff changeset
171 \ }
a3fce2763e83 patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents: 18900
diff changeset
172 \ ]
a3fce2763e83 patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents: 18900
diff changeset
173 \ }
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 14489
diff changeset
174 endfunc
13238
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
175
15416
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
176 func s:CompleteDone_CheckCompletedItemNone()
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
177 let s:called_completedone = 1
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
178 endfunc
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
179
19199
8cbadf7fb9d4 patch 8.2.0158: triggering CompleteDone earlier is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 19127
diff changeset
180 func s:CompleteDone_CheckCompletedItemDict(pre)
13238
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
181 call assert_equal( 'aword', v:completed_item[ 'word' ] )
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
182 call assert_equal( 'wrd', v:completed_item[ 'abbr' ] )
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
183 call assert_equal( 'extra text', v:completed_item[ 'menu' ] )
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
184 call assert_equal( 'words are cool', v:completed_item[ 'info' ] )
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
185 call assert_equal( 'W', v:completed_item[ 'kind' ] )
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
186 call assert_equal( 'test', v:completed_item[ 'user_data' ] )
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
187
19199
8cbadf7fb9d4 patch 8.2.0158: triggering CompleteDone earlier is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 19127
diff changeset
188 if a:pre
8cbadf7fb9d4 patch 8.2.0158: triggering CompleteDone earlier is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 19127
diff changeset
189 call assert_equal('function', complete_info().mode)
8cbadf7fb9d4 patch 8.2.0158: triggering CompleteDone earlier is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 19127
diff changeset
190 endif
19127
0ee48dc3f8bc patch 8.2.0123: complete_info() does not work when CompleteDone is triggered
Bram Moolenaar <Bram@vim.org>
parents: 19055
diff changeset
191
13238
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
192 let s:called_completedone = 1
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 14489
diff changeset
193 endfunc
13238
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
194
15416
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
195 func Test_CompleteDoneNone()
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
196 au CompleteDone * :call <SID>CompleteDone_CheckCompletedItemNone()
16270
749a7c03de8d patch 8.1.1139: no test for what is fixed in patch 8.1.0716
Bram Moolenaar <Bram@vim.org>
parents: 15416
diff changeset
197 let oldline = join(map(range(&columns), 'nr2char(screenchar(&lines-1, v:val+1))'), '')
15416
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
198
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
199 set completefunc=<SID>CompleteDone_CompleteFuncNone
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
200 execute "normal a\<C-X>\<C-U>\<C-Y>"
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
201 set completefunc&
16270
749a7c03de8d patch 8.1.1139: no test for what is fixed in patch 8.1.0716
Bram Moolenaar <Bram@vim.org>
parents: 15416
diff changeset
202 let newline = join(map(range(&columns), 'nr2char(screenchar(&lines-1, v:val+1))'), '')
15416
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
203
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
204 call assert_true(s:called_completedone)
16270
749a7c03de8d patch 8.1.1139: no test for what is fixed in patch 8.1.0716
Bram Moolenaar <Bram@vim.org>
parents: 15416
diff changeset
205 call assert_equal(oldline, newline)
15416
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
206
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
207 let s:called_completedone = 0
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
208 au! CompleteDone
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
209 endfunc
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
210
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
211 func Test_CompleteDoneDict()
19199
8cbadf7fb9d4 patch 8.2.0158: triggering CompleteDone earlier is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 19127
diff changeset
212 au CompleteDonePre * :call <SID>CompleteDone_CheckCompletedItemDict(1)
8cbadf7fb9d4 patch 8.2.0158: triggering CompleteDone earlier is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 19127
diff changeset
213 au CompleteDone * :call <SID>CompleteDone_CheckCompletedItemDict(0)
13238
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
214
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
215 set completefunc=<SID>CompleteDone_CompleteFuncDict
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
216 execute "normal a\<C-X>\<C-U>\<C-Y>"
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
217 set completefunc&
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
218
15416
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
219 call assert_equal('test', v:completed_item[ 'user_data' ])
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
220 call assert_true(s:called_completedone)
13238
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
221
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
222 let s:called_completedone = 0
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
223 au! CompleteDone
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
224 endfunc
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
225
15416
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
226 func s:CompleteDone_CompleteFuncDictNoUserData(findstart, base)
13238
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
227 if a:findstart
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
228 return 0
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
229 endif
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
230
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
231 return {
19047
a3fce2763e83 patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents: 18900
diff changeset
232 \ 'words': [
a3fce2763e83 patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents: 18900
diff changeset
233 \ {
a3fce2763e83 patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents: 18900
diff changeset
234 \ 'word': 'aword',
a3fce2763e83 patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents: 18900
diff changeset
235 \ 'abbr': 'wrd',
a3fce2763e83 patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents: 18900
diff changeset
236 \ 'menu': 'extra text',
a3fce2763e83 patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents: 18900
diff changeset
237 \ 'info': 'words are cool',
a3fce2763e83 patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents: 18900
diff changeset
238 \ 'kind': 'W',
a3fce2763e83 patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents: 18900
diff changeset
239 \ 'user_data': ['one', 'two'],
a3fce2763e83 patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents: 18900
diff changeset
240 \ }
a3fce2763e83 patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents: 18900
diff changeset
241 \ ]
a3fce2763e83 patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents: 18900
diff changeset
242 \ }
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 14489
diff changeset
243 endfunc
13238
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
244
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 14489
diff changeset
245 func s:CompleteDone_CheckCompletedItemDictNoUserData()
13238
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
246 call assert_equal( 'aword', v:completed_item[ 'word' ] )
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
247 call assert_equal( 'wrd', v:completed_item[ 'abbr' ] )
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
248 call assert_equal( 'extra text', v:completed_item[ 'menu' ] )
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
249 call assert_equal( 'words are cool', v:completed_item[ 'info' ] )
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
250 call assert_equal( 'W', v:completed_item[ 'kind' ] )
19047
a3fce2763e83 patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents: 18900
diff changeset
251 call assert_equal( ['one', 'two'], v:completed_item[ 'user_data' ] )
13238
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
252
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
253 let s:called_completedone = 1
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 14489
diff changeset
254 endfunc
13238
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
255
15416
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
256 func Test_CompleteDoneDictNoUserData()
13238
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
257 au CompleteDone * :call <SID>CompleteDone_CheckCompletedItemDictNoUserData()
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
258
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
259 set completefunc=<SID>CompleteDone_CompleteFuncDictNoUserData
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
260 execute "normal a\<C-X>\<C-U>\<C-Y>"
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
261 set completefunc&
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
262
19047
a3fce2763e83 patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents: 18900
diff changeset
263 call assert_equal(['one', 'two'], v:completed_item[ 'user_data' ])
15416
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
264 call assert_true(s:called_completedone)
13238
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
265
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
266 let s:called_completedone = 0
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
267 au! CompleteDone
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
268 endfunc
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
269
15416
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
270 func s:CompleteDone_CompleteFuncList(findstart, base)
13238
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
271 if a:findstart
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
272 return 0
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
273 endif
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
274
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
275 return [ 'aword' ]
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 14489
diff changeset
276 endfunc
13238
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
277
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 14489
diff changeset
278 func s:CompleteDone_CheckCompletedItemList()
13238
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
279 call assert_equal( 'aword', v:completed_item[ 'word' ] )
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
280 call assert_equal( '', v:completed_item[ 'abbr' ] )
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
281 call assert_equal( '', v:completed_item[ 'menu' ] )
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
282 call assert_equal( '', v:completed_item[ 'info' ] )
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
283 call assert_equal( '', v:completed_item[ 'kind' ] )
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
284 call assert_equal( '', v:completed_item[ 'user_data' ] )
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
285
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
286 let s:called_completedone = 1
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 14489
diff changeset
287 endfunc
13238
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
288
15416
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
289 func Test_CompleteDoneList()
13238
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
290 au CompleteDone * :call <SID>CompleteDone_CheckCompletedItemList()
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
291
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
292 set completefunc=<SID>CompleteDone_CompleteFuncList
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
293 execute "normal a\<C-X>\<C-U>\<C-Y>"
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
294 set completefunc&
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
295
15416
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
296 call assert_equal('', v:completed_item[ 'user_data' ])
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
297 call assert_true(s:called_completedone)
13238
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
298
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
299 let s:called_completedone = 0
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
300 au! CompleteDone
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
301 endfunc
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
302
14489
cda216729f9b patch 8.1.0258: not enough testing for the CompleteDone event
Christian Brabandt <cb@256bit.org>
parents: 14075
diff changeset
303 func Test_CompleteDone_undo()
cda216729f9b patch 8.1.0258: not enough testing for the CompleteDone event
Christian Brabandt <cb@256bit.org>
parents: 14075
diff changeset
304 au CompleteDone * call append(0, "prepend1")
cda216729f9b patch 8.1.0258: not enough testing for the CompleteDone event
Christian Brabandt <cb@256bit.org>
parents: 14075
diff changeset
305 new
cda216729f9b patch 8.1.0258: not enough testing for the CompleteDone event
Christian Brabandt <cb@256bit.org>
parents: 14075
diff changeset
306 call setline(1, ["line1", "line2"])
cda216729f9b patch 8.1.0258: not enough testing for the CompleteDone event
Christian Brabandt <cb@256bit.org>
parents: 14075
diff changeset
307 call feedkeys("Go\<C-X>\<C-N>\<CR>\<ESC>", "tx")
cda216729f9b patch 8.1.0258: not enough testing for the CompleteDone event
Christian Brabandt <cb@256bit.org>
parents: 14075
diff changeset
308 call assert_equal(["prepend1", "line1", "line2", "line1", ""],
cda216729f9b patch 8.1.0258: not enough testing for the CompleteDone event
Christian Brabandt <cb@256bit.org>
parents: 14075
diff changeset
309 \ getline(1, '$'))
cda216729f9b patch 8.1.0258: not enough testing for the CompleteDone event
Christian Brabandt <cb@256bit.org>
parents: 14075
diff changeset
310 undo
cda216729f9b patch 8.1.0258: not enough testing for the CompleteDone event
Christian Brabandt <cb@256bit.org>
parents: 14075
diff changeset
311 call assert_equal(["line1", "line2"], getline(1, '$'))
cda216729f9b patch 8.1.0258: not enough testing for the CompleteDone event
Christian Brabandt <cb@256bit.org>
parents: 14075
diff changeset
312 bwipe!
cda216729f9b patch 8.1.0258: not enough testing for the CompleteDone event
Christian Brabandt <cb@256bit.org>
parents: 14075
diff changeset
313 au! CompleteDone
cda216729f9b patch 8.1.0258: not enough testing for the CompleteDone event
Christian Brabandt <cb@256bit.org>
parents: 14075
diff changeset
314 endfunc
cda216729f9b patch 8.1.0258: not enough testing for the CompleteDone event
Christian Brabandt <cb@256bit.org>
parents: 14075
diff changeset
315
22248
80a000b09cb0 patch 8.2.1673: complete_info() selected index has an invalid value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
316 func CompleteTest(findstart, query)
80a000b09cb0 patch 8.2.1673: complete_info() selected index has an invalid value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
317 if a:findstart
80a000b09cb0 patch 8.2.1673: complete_info() selected index has an invalid value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
318 return col('.')
80a000b09cb0 patch 8.2.1673: complete_info() selected index has an invalid value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
319 endif
80a000b09cb0 patch 8.2.1673: complete_info() selected index has an invalid value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
320 return ['matched']
80a000b09cb0 patch 8.2.1673: complete_info() selected index has an invalid value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
321 endfunc
80a000b09cb0 patch 8.2.1673: complete_info() selected index has an invalid value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
322
80a000b09cb0 patch 8.2.1673: complete_info() selected index has an invalid value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
323 func Test_completefunc_info()
80a000b09cb0 patch 8.2.1673: complete_info() selected index has an invalid value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
324 new
80a000b09cb0 patch 8.2.1673: complete_info() selected index has an invalid value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
325 set completeopt=menuone
80a000b09cb0 patch 8.2.1673: complete_info() selected index has an invalid value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
326 set completefunc=CompleteTest
80a000b09cb0 patch 8.2.1673: complete_info() selected index has an invalid value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
327 call feedkeys("i\<C-X>\<C-U>\<C-R>\<C-R>=string(complete_info())\<CR>\<ESC>", "tx")
22717
bd61aaf7f2a0 patch 8.2.1907: complete_info().selected may be wrong
Bram Moolenaar <Bram@vim.org>
parents: 22705
diff changeset
328 call assert_equal("matched{'pum_visible': 1, 'mode': 'function', 'selected': 0, 'items': [{'word': 'matched', 'menu': '', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''}]}", getline(1))
22248
80a000b09cb0 patch 8.2.1673: complete_info() selected index has an invalid value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
329 bwipe!
80a000b09cb0 patch 8.2.1673: complete_info() selected index has an invalid value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
330 set completeopt&
80a000b09cb0 patch 8.2.1673: complete_info() selected index has an invalid value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
331 set completefunc&
80a000b09cb0 patch 8.2.1673: complete_info() selected index has an invalid value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
332 endfunc
80a000b09cb0 patch 8.2.1673: complete_info() selected index has an invalid value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
333
13215
ae5f855a64be patch 8.0.1482: using feedkeys() does not work to test completion
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
334 " Check that when using feedkeys() typeahead does not interrupt searching for
ae5f855a64be patch 8.0.1482: using feedkeys() does not work to test completion
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
335 " completions.
ae5f855a64be patch 8.0.1482: using feedkeys() does not work to test completion
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
336 func Test_compl_feedkeys()
ae5f855a64be patch 8.0.1482: using feedkeys() does not work to test completion
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
337 new
ae5f855a64be patch 8.0.1482: using feedkeys() does not work to test completion
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
338 set completeopt=menuone,noselect
ae5f855a64be patch 8.0.1482: using feedkeys() does not work to test completion
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
339 call feedkeys("ajump ju\<C-X>\<C-N>\<C-P>\<ESC>", "tx")
ae5f855a64be patch 8.0.1482: using feedkeys() does not work to test completion
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
340 call assert_equal("jump jump", getline(1))
ae5f855a64be patch 8.0.1482: using feedkeys() does not work to test completion
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
341 bwipe!
ae5f855a64be patch 8.0.1482: using feedkeys() does not work to test completion
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
342 set completeopt&
ae5f855a64be patch 8.0.1482: using feedkeys() does not work to test completion
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
343 endfunc
17468
fa6c9047ec70 patch 8.1.1732: completion in cmdwin does not work for buffer-local commands
Bram Moolenaar <Bram@vim.org>
parents: 16270
diff changeset
344
fa6c9047ec70 patch 8.1.1732: completion in cmdwin does not work for buffer-local commands
Bram Moolenaar <Bram@vim.org>
parents: 16270
diff changeset
345 func Test_compl_in_cmdwin()
23748
93f90f2ff4e9 patch 8.2.2415: no way to check for the cmdwin feature
Bram Moolenaar <Bram@vim.org>
parents: 23169
diff changeset
346 CheckFeature cmdwin
93f90f2ff4e9 patch 8.2.2415: no way to check for the cmdwin feature
Bram Moolenaar <Bram@vim.org>
parents: 23169
diff changeset
347
17468
fa6c9047ec70 patch 8.1.1732: completion in cmdwin does not work for buffer-local commands
Bram Moolenaar <Bram@vim.org>
parents: 16270
diff changeset
348 set wildmenu wildchar=<Tab>
fa6c9047ec70 patch 8.1.1732: completion in cmdwin does not work for buffer-local commands
Bram Moolenaar <Bram@vim.org>
parents: 16270
diff changeset
349 com! -nargs=1 -complete=command GetInput let input = <q-args>
fa6c9047ec70 patch 8.1.1732: completion in cmdwin does not work for buffer-local commands
Bram Moolenaar <Bram@vim.org>
parents: 16270
diff changeset
350 com! -buffer TestCommand echo 'TestCommand'
22705
ba3f547dc490 patch 8.2.1901: variable completion does not work in command line window
Bram Moolenaar <Bram@vim.org>
parents: 22427
diff changeset
351 let w:test_winvar = 'winvar'
ba3f547dc490 patch 8.2.1901: variable completion does not work in command line window
Bram Moolenaar <Bram@vim.org>
parents: 22427
diff changeset
352 let b:test_bufvar = 'bufvar'
17468
fa6c9047ec70 patch 8.1.1732: completion in cmdwin does not work for buffer-local commands
Bram Moolenaar <Bram@vim.org>
parents: 16270
diff changeset
353
22705
ba3f547dc490 patch 8.2.1901: variable completion does not work in command line window
Bram Moolenaar <Bram@vim.org>
parents: 22427
diff changeset
354 " User-defined commands
17468
fa6c9047ec70 patch 8.1.1732: completion in cmdwin does not work for buffer-local commands
Bram Moolenaar <Bram@vim.org>
parents: 16270
diff changeset
355 let input = ''
fa6c9047ec70 patch 8.1.1732: completion in cmdwin does not work for buffer-local commands
Bram Moolenaar <Bram@vim.org>
parents: 16270
diff changeset
356 call feedkeys("q:iGetInput T\<C-x>\<C-v>\<CR>", 'tx!')
fa6c9047ec70 patch 8.1.1732: completion in cmdwin does not work for buffer-local commands
Bram Moolenaar <Bram@vim.org>
parents: 16270
diff changeset
357 call assert_equal('TestCommand', input)
fa6c9047ec70 patch 8.1.1732: completion in cmdwin does not work for buffer-local commands
Bram Moolenaar <Bram@vim.org>
parents: 16270
diff changeset
358
fa6c9047ec70 patch 8.1.1732: completion in cmdwin does not work for buffer-local commands
Bram Moolenaar <Bram@vim.org>
parents: 16270
diff changeset
359 let input = ''
fa6c9047ec70 patch 8.1.1732: completion in cmdwin does not work for buffer-local commands
Bram Moolenaar <Bram@vim.org>
parents: 16270
diff changeset
360 call feedkeys("q::GetInput T\<Tab>\<CR>:q\<CR>", 'tx!')
fa6c9047ec70 patch 8.1.1732: completion in cmdwin does not work for buffer-local commands
Bram Moolenaar <Bram@vim.org>
parents: 16270
diff changeset
361 call assert_equal('T', input)
fa6c9047ec70 patch 8.1.1732: completion in cmdwin does not work for buffer-local commands
Bram Moolenaar <Bram@vim.org>
parents: 16270
diff changeset
362
22705
ba3f547dc490 patch 8.2.1901: variable completion does not work in command line window
Bram Moolenaar <Bram@vim.org>
parents: 22427
diff changeset
363
ba3f547dc490 patch 8.2.1901: variable completion does not work in command line window
Bram Moolenaar <Bram@vim.org>
parents: 22427
diff changeset
364 com! -nargs=1 -complete=var GetInput let input = <q-args>
ba3f547dc490 patch 8.2.1901: variable completion does not work in command line window
Bram Moolenaar <Bram@vim.org>
parents: 22427
diff changeset
365 " Window-local variables
ba3f547dc490 patch 8.2.1901: variable completion does not work in command line window
Bram Moolenaar <Bram@vim.org>
parents: 22427
diff changeset
366 let input = ''
ba3f547dc490 patch 8.2.1901: variable completion does not work in command line window
Bram Moolenaar <Bram@vim.org>
parents: 22427
diff changeset
367 call feedkeys("q:iGetInput w:test_\<C-x>\<C-v>\<CR>", 'tx!')
ba3f547dc490 patch 8.2.1901: variable completion does not work in command line window
Bram Moolenaar <Bram@vim.org>
parents: 22427
diff changeset
368 call assert_equal('w:test_winvar', input)
ba3f547dc490 patch 8.2.1901: variable completion does not work in command line window
Bram Moolenaar <Bram@vim.org>
parents: 22427
diff changeset
369
ba3f547dc490 patch 8.2.1901: variable completion does not work in command line window
Bram Moolenaar <Bram@vim.org>
parents: 22427
diff changeset
370 let input = ''
ba3f547dc490 patch 8.2.1901: variable completion does not work in command line window
Bram Moolenaar <Bram@vim.org>
parents: 22427
diff changeset
371 call feedkeys("q::GetInput w:test_\<Tab>\<CR>:q\<CR>", 'tx!')
ba3f547dc490 patch 8.2.1901: variable completion does not work in command line window
Bram Moolenaar <Bram@vim.org>
parents: 22427
diff changeset
372 call assert_equal('w:test_', input)
ba3f547dc490 patch 8.2.1901: variable completion does not work in command line window
Bram Moolenaar <Bram@vim.org>
parents: 22427
diff changeset
373
ba3f547dc490 patch 8.2.1901: variable completion does not work in command line window
Bram Moolenaar <Bram@vim.org>
parents: 22427
diff changeset
374 " Buffer-local variables
ba3f547dc490 patch 8.2.1901: variable completion does not work in command line window
Bram Moolenaar <Bram@vim.org>
parents: 22427
diff changeset
375 let input = ''
ba3f547dc490 patch 8.2.1901: variable completion does not work in command line window
Bram Moolenaar <Bram@vim.org>
parents: 22427
diff changeset
376 call feedkeys("q:iGetInput b:test_\<C-x>\<C-v>\<CR>", 'tx!')
ba3f547dc490 patch 8.2.1901: variable completion does not work in command line window
Bram Moolenaar <Bram@vim.org>
parents: 22427
diff changeset
377 call assert_equal('b:test_bufvar', input)
ba3f547dc490 patch 8.2.1901: variable completion does not work in command line window
Bram Moolenaar <Bram@vim.org>
parents: 22427
diff changeset
378
ba3f547dc490 patch 8.2.1901: variable completion does not work in command line window
Bram Moolenaar <Bram@vim.org>
parents: 22427
diff changeset
379 let input = ''
ba3f547dc490 patch 8.2.1901: variable completion does not work in command line window
Bram Moolenaar <Bram@vim.org>
parents: 22427
diff changeset
380 call feedkeys("q::GetInput b:test_\<Tab>\<CR>:q\<CR>", 'tx!')
ba3f547dc490 patch 8.2.1901: variable completion does not work in command line window
Bram Moolenaar <Bram@vim.org>
parents: 22427
diff changeset
381 call assert_equal('b:test_', input)
ba3f547dc490 patch 8.2.1901: variable completion does not work in command line window
Bram Moolenaar <Bram@vim.org>
parents: 22427
diff changeset
382
17468
fa6c9047ec70 patch 8.1.1732: completion in cmdwin does not work for buffer-local commands
Bram Moolenaar <Bram@vim.org>
parents: 16270
diff changeset
383 delcom TestCommand
fa6c9047ec70 patch 8.1.1732: completion in cmdwin does not work for buffer-local commands
Bram Moolenaar <Bram@vim.org>
parents: 16270
diff changeset
384 delcom GetInput
22705
ba3f547dc490 patch 8.2.1901: variable completion does not work in command line window
Bram Moolenaar <Bram@vim.org>
parents: 22427
diff changeset
385 unlet w:test_winvar
ba3f547dc490 patch 8.2.1901: variable completion does not work in command line window
Bram Moolenaar <Bram@vim.org>
parents: 22427
diff changeset
386 unlet b:test_bufvar
17468
fa6c9047ec70 patch 8.1.1732: completion in cmdwin does not work for buffer-local commands
Bram Moolenaar <Bram@vim.org>
parents: 16270
diff changeset
387 set wildmenu& wildchar&
fa6c9047ec70 patch 8.1.1732: completion in cmdwin does not work for buffer-local commands
Bram Moolenaar <Bram@vim.org>
parents: 16270
diff changeset
388 endfunc
17543
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
389
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
390 " Test for insert path completion with completeslash option
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
391 func Test_ins_completeslash()
17588
1348696d07cd patch 8.1.1791: 'completeslash' also applies to globpath()
Bram Moolenaar <Bram@vim.org>
parents: 17553
diff changeset
392 CheckMSWindows
22397
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22248
diff changeset
393
17543
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
394 call mkdir('Xdir')
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
395 let orig_shellslash = &shellslash
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
396 set cpt&
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
397 new
22397
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22248
diff changeset
398
17543
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
399 set noshellslash
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
400
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
401 set completeslash=
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
402 exe "normal oXd\<C-X>\<C-F>"
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
403 call assert_equal('Xdir\', getline('.'))
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
404
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
405 set completeslash=backslash
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
406 exe "normal oXd\<C-X>\<C-F>"
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
407 call assert_equal('Xdir\', getline('.'))
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
408
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
409 set completeslash=slash
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
410 exe "normal oXd\<C-X>\<C-F>"
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
411 call assert_equal('Xdir/', getline('.'))
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
412
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
413 set shellslash
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
414
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
415 set completeslash=
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
416 exe "normal oXd\<C-X>\<C-F>"
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
417 call assert_equal('Xdir/', getline('.'))
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
418
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
419 set completeslash=backslash
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
420 exe "normal oXd\<C-X>\<C-F>"
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
421 call assert_equal('Xdir\', getline('.'))
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
422
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
423 set completeslash=slash
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
424 exe "normal oXd\<C-X>\<C-F>"
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
425 call assert_equal('Xdir/', getline('.'))
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
426 %bw!
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
427 call delete('Xdir', 'rf')
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
428
17588
1348696d07cd patch 8.1.1791: 'completeslash' also applies to globpath()
Bram Moolenaar <Bram@vim.org>
parents: 17553
diff changeset
429 set noshellslash
1348696d07cd patch 8.1.1791: 'completeslash' also applies to globpath()
Bram Moolenaar <Bram@vim.org>
parents: 17553
diff changeset
430 set completeslash=slash
1348696d07cd patch 8.1.1791: 'completeslash' also applies to globpath()
Bram Moolenaar <Bram@vim.org>
parents: 17553
diff changeset
431 call assert_true(stridx(globpath(&rtp, 'syntax/*.vim', 1, 1)[0], '\') != -1)
1348696d07cd patch 8.1.1791: 'completeslash' also applies to globpath()
Bram Moolenaar <Bram@vim.org>
parents: 17553
diff changeset
432
17543
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
433 let &shellslash = orig_shellslash
17588
1348696d07cd patch 8.1.1791: 'completeslash' also applies to globpath()
Bram Moolenaar <Bram@vim.org>
parents: 17553
diff changeset
434 set completeslash=
17543
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
435 endfunc
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
436
22427
58cdc5d7f143 patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
437 func Test_pum_stopped_by_timer()
58cdc5d7f143 patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
438 CheckScreendump
58cdc5d7f143 patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
439
58cdc5d7f143 patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
440 let lines =<< trim END
58cdc5d7f143 patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
441 call setline(1, ['hello', 'hullo', 'heeee', ''])
58cdc5d7f143 patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
442 func StartCompl()
58cdc5d7f143 patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
443 call timer_start(100, { -> execute('stopinsert') })
58cdc5d7f143 patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
444 call feedkeys("Gah\<C-N>")
58cdc5d7f143 patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
445 endfunc
58cdc5d7f143 patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
446 END
58cdc5d7f143 patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
447
58cdc5d7f143 patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
448 call writefile(lines, 'Xpumscript')
58cdc5d7f143 patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
449 let buf = RunVimInTerminal('-S Xpumscript', #{rows: 12})
58cdc5d7f143 patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
450 call term_sendkeys(buf, ":call StartCompl()\<CR>")
58cdc5d7f143 patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
451 call TermWait(buf, 200)
58cdc5d7f143 patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
452 call term_sendkeys(buf, "k")
58cdc5d7f143 patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
453 call VerifyScreenDump(buf, 'Test_pum_stopped_by_timer', {})
58cdc5d7f143 patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
454
58cdc5d7f143 patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
455 call StopVimInTerminal(buf)
58cdc5d7f143 patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
456 call delete('Xpumscript')
58cdc5d7f143 patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
457 endfunc
58cdc5d7f143 patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
458
18892
fb2d26bc8ca1 patch 8.2.0007: popup menu positioned wrong with folding in two tabs
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
459 func Test_pum_with_folds_two_tabs()
fb2d26bc8ca1 patch 8.2.0007: popup menu positioned wrong with folding in two tabs
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
460 CheckScreendump
fb2d26bc8ca1 patch 8.2.0007: popup menu positioned wrong with folding in two tabs
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
461
fb2d26bc8ca1 patch 8.2.0007: popup menu positioned wrong with folding in two tabs
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
462 let lines =<< trim END
fb2d26bc8ca1 patch 8.2.0007: popup menu positioned wrong with folding in two tabs
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
463 set fdm=marker
fb2d26bc8ca1 patch 8.2.0007: popup menu positioned wrong with folding in two tabs
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
464 call setline(1, ['" x {{{1', '" a some text'])
fb2d26bc8ca1 patch 8.2.0007: popup menu positioned wrong with folding in two tabs
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
465 call setline(3, range(&lines)->map({_, val -> '" a' .. val}))
fb2d26bc8ca1 patch 8.2.0007: popup menu positioned wrong with folding in two tabs
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
466 norm! zm
fb2d26bc8ca1 patch 8.2.0007: popup menu positioned wrong with folding in two tabs
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
467 tab sp
fb2d26bc8ca1 patch 8.2.0007: popup menu positioned wrong with folding in two tabs
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
468 call feedkeys('2Gzv', 'xt')
fb2d26bc8ca1 patch 8.2.0007: popup menu positioned wrong with folding in two tabs
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
469 call feedkeys("0fa", 'xt')
fb2d26bc8ca1 patch 8.2.0007: popup menu positioned wrong with folding in two tabs
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
470 END
fb2d26bc8ca1 patch 8.2.0007: popup menu positioned wrong with folding in two tabs
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
471
fb2d26bc8ca1 patch 8.2.0007: popup menu positioned wrong with folding in two tabs
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
472 call writefile(lines, 'Xpumscript')
fb2d26bc8ca1 patch 8.2.0007: popup menu positioned wrong with folding in two tabs
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
473 let buf = RunVimInTerminal('-S Xpumscript', #{rows: 10})
19954
c087099e9163 patch 8.2.0533: tests using term_wait() can still be flaky
Bram Moolenaar <Bram@vim.org>
parents: 19932
diff changeset
474 call TermWait(buf, 50)
18892
fb2d26bc8ca1 patch 8.2.0007: popup menu positioned wrong with folding in two tabs
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
475 call term_sendkeys(buf, "a\<C-N>")
fb2d26bc8ca1 patch 8.2.0007: popup menu positioned wrong with folding in two tabs
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
476 call VerifyScreenDump(buf, 'Test_pum_with_folds_two_tabs', {})
fb2d26bc8ca1 patch 8.2.0007: popup menu positioned wrong with folding in two tabs
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
477
fb2d26bc8ca1 patch 8.2.0007: popup menu positioned wrong with folding in two tabs
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
478 call term_sendkeys(buf, "\<Esc>")
fb2d26bc8ca1 patch 8.2.0007: popup menu positioned wrong with folding in two tabs
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
479 call StopVimInTerminal(buf)
fb2d26bc8ca1 patch 8.2.0007: popup menu positioned wrong with folding in two tabs
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
480 call delete('Xpumscript')
fb2d26bc8ca1 patch 8.2.0007: popup menu positioned wrong with folding in two tabs
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
481 endfunc
18900
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
482
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
483 func Test_pum_with_preview_win()
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
484 CheckScreendump
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
485
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
486 let lines =<< trim END
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
487 funct Omni_test(findstart, base)
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
488 if a:findstart
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
489 return col(".") - 1
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
490 endif
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
491 return [#{word: "one", info: "1info"}, #{word: "two", info: "2info"}, #{word: "three", info: "3info"}]
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
492 endfunc
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
493 set omnifunc=Omni_test
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
494 set completeopt+=longest
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
495 END
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
496
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
497 call writefile(lines, 'Xpreviewscript')
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
498 let buf = RunVimInTerminal('-S Xpreviewscript', #{rows: 12})
19954
c087099e9163 patch 8.2.0533: tests using term_wait() can still be flaky
Bram Moolenaar <Bram@vim.org>
parents: 19932
diff changeset
499 call TermWait(buf, 50)
18900
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
500 call term_sendkeys(buf, "Gi\<C-X>\<C-O>")
19954
c087099e9163 patch 8.2.0533: tests using term_wait() can still be flaky
Bram Moolenaar <Bram@vim.org>
parents: 19932
diff changeset
501 call TermWait(buf, 100)
18900
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
502 call term_sendkeys(buf, "\<C-N>")
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
503 call VerifyScreenDump(buf, 'Test_pum_with_preview_win', {})
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
504
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
505 call term_sendkeys(buf, "\<Esc>")
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
506 call StopVimInTerminal(buf)
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
507 call delete('Xpreviewscript')
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
508 endfunc
19055
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 19047
diff changeset
509
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 19047
diff changeset
510 " Test for inserting the tag search pattern in insert mode
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 19047
diff changeset
511 func Test_ins_compl_tag_sft()
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 19047
diff changeset
512 call writefile([
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 19047
diff changeset
513 \ "!_TAG_FILE_ENCODING\tutf-8\t//",
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 19047
diff changeset
514 \ "first\tXfoo\t/^int first() {}$/",
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 19047
diff changeset
515 \ "second\tXfoo\t/^int second() {}$/",
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 19047
diff changeset
516 \ "third\tXfoo\t/^int third() {}$/"],
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 19047
diff changeset
517 \ 'Xtags')
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 19047
diff changeset
518 set tags=Xtags
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 19047
diff changeset
519 let code =<< trim [CODE]
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 19047
diff changeset
520 int first() {}
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 19047
diff changeset
521 int second() {}
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 19047
diff changeset
522 int third() {}
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 19047
diff changeset
523 [CODE]
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 19047
diff changeset
524 call writefile(code, 'Xfoo')
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 19047
diff changeset
525
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 19047
diff changeset
526 enew
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 19047
diff changeset
527 set showfulltag
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 19047
diff changeset
528 exe "normal isec\<C-X>\<C-]>\<C-N>\<CR>"
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 19047
diff changeset
529 call assert_equal('int second() {}', getline(1))
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 19047
diff changeset
530 set noshowfulltag
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 19047
diff changeset
531
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 19047
diff changeset
532 call delete('Xtags')
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 19047
diff changeset
533 call delete('Xfoo')
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 19047
diff changeset
534 set tags&
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 19047
diff changeset
535 %bwipe!
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 19047
diff changeset
536 endfunc
19932
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19651
diff changeset
537
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19651
diff changeset
538 " Test for 'completefunc' deleting text
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19651
diff changeset
539 func Test_completefunc_error()
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19651
diff changeset
540 new
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
541 " delete text when called for the first time
19932
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19651
diff changeset
542 func CompleteFunc(findstart, base)
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19651
diff changeset
543 if a:findstart == 1
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19651
diff changeset
544 normal dd
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19651
diff changeset
545 return col('.') - 1
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19651
diff changeset
546 endif
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19651
diff changeset
547 return ['a', 'b']
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19651
diff changeset
548 endfunc
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19651
diff changeset
549 set completefunc=CompleteFunc
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19651
diff changeset
550 call setline(1, ['', 'abcd', ''])
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19651
diff changeset
551 call assert_fails('exe "normal 2G$a\<C-X>\<C-U>"', 'E840:')
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
552
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
553 " delete text when called for the second time
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
554 func CompleteFunc2(findstart, base)
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
555 if a:findstart == 1
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
556 return col('.') - 1
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
557 endif
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
558 normal dd
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
559 return ['a', 'b']
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
560 endfunc
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
561 set completefunc=CompleteFunc2
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
562 call setline(1, ['', 'abcd', ''])
20229
06a1dd50463e patch 8.2.0670: cannot change window when evaluating 'completefunc'
Bram Moolenaar <Bram@vim.org>
parents: 20199
diff changeset
563 call assert_fails('exe "normal 2G$a\<C-X>\<C-U>"', 'E578:')
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
564
23766
704fdd4d0949 patch 8.2.2424: some tests are known to cause an error with ASAN
Bram Moolenaar <Bram@vim.org>
parents: 23748
diff changeset
565 " Jump to a different window from the complete function
23770
385d33dfb7df patch 8.2.2426: allowing 'completefunc' to switch windows causes trouble
Bram Moolenaar <Bram@vim.org>
parents: 23766
diff changeset
566 func CompleteFunc3(findstart, base)
23766
704fdd4d0949 patch 8.2.2424: some tests are known to cause an error with ASAN
Bram Moolenaar <Bram@vim.org>
parents: 23748
diff changeset
567 if a:findstart == 1
704fdd4d0949 patch 8.2.2424: some tests are known to cause an error with ASAN
Bram Moolenaar <Bram@vim.org>
parents: 23748
diff changeset
568 return col('.') - 1
704fdd4d0949 patch 8.2.2424: some tests are known to cause an error with ASAN
Bram Moolenaar <Bram@vim.org>
parents: 23748
diff changeset
569 endif
704fdd4d0949 patch 8.2.2424: some tests are known to cause an error with ASAN
Bram Moolenaar <Bram@vim.org>
parents: 23748
diff changeset
570 wincmd p
704fdd4d0949 patch 8.2.2424: some tests are known to cause an error with ASAN
Bram Moolenaar <Bram@vim.org>
parents: 23748
diff changeset
571 return ['a', 'b']
704fdd4d0949 patch 8.2.2424: some tests are known to cause an error with ASAN
Bram Moolenaar <Bram@vim.org>
parents: 23748
diff changeset
572 endfunc
23770
385d33dfb7df patch 8.2.2426: allowing 'completefunc' to switch windows causes trouble
Bram Moolenaar <Bram@vim.org>
parents: 23766
diff changeset
573 set completefunc=CompleteFunc3
23766
704fdd4d0949 patch 8.2.2424: some tests are known to cause an error with ASAN
Bram Moolenaar <Bram@vim.org>
parents: 23748
diff changeset
574 new
23770
385d33dfb7df patch 8.2.2426: allowing 'completefunc' to switch windows causes trouble
Bram Moolenaar <Bram@vim.org>
parents: 23766
diff changeset
575 call assert_fails('exe "normal a\<C-X>\<C-U>"', 'E565:')
23766
704fdd4d0949 patch 8.2.2424: some tests are known to cause an error with ASAN
Bram Moolenaar <Bram@vim.org>
parents: 23748
diff changeset
576 close!
704fdd4d0949 patch 8.2.2424: some tests are known to cause an error with ASAN
Bram Moolenaar <Bram@vim.org>
parents: 23748
diff changeset
577
704fdd4d0949 patch 8.2.2424: some tests are known to cause an error with ASAN
Bram Moolenaar <Bram@vim.org>
parents: 23748
diff changeset
578 set completefunc&
704fdd4d0949 patch 8.2.2424: some tests are known to cause an error with ASAN
Bram Moolenaar <Bram@vim.org>
parents: 23748
diff changeset
579 delfunc CompleteFunc
23770
385d33dfb7df patch 8.2.2426: allowing 'completefunc' to switch windows causes trouble
Bram Moolenaar <Bram@vim.org>
parents: 23766
diff changeset
580 delfunc CompleteFunc2
385d33dfb7df patch 8.2.2426: allowing 'completefunc' to switch windows causes trouble
Bram Moolenaar <Bram@vim.org>
parents: 23766
diff changeset
581 delfunc CompleteFunc3
385d33dfb7df patch 8.2.2426: allowing 'completefunc' to switch windows causes trouble
Bram Moolenaar <Bram@vim.org>
parents: 23766
diff changeset
582 close!
23766
704fdd4d0949 patch 8.2.2424: some tests are known to cause an error with ASAN
Bram Moolenaar <Bram@vim.org>
parents: 23748
diff changeset
583 endfunc
704fdd4d0949 patch 8.2.2424: some tests are known to cause an error with ASAN
Bram Moolenaar <Bram@vim.org>
parents: 23748
diff changeset
584
20285
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
585 " Test for returning non-string values from 'completefunc'
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
586 func Test_completefunc_invalid_data()
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
587 new
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
588 func! CompleteFunc(findstart, base)
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
589 if a:findstart == 1
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
590 return col('.') - 1
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
591 endif
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
592 return [{}, '', 'moon']
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
593 endfunc
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
594 set completefunc=CompleteFunc
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
595 exe "normal i\<C-X>\<C-U>"
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
596 call assert_equal('moon', getline(1))
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
597 set completefunc&
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
598 close!
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
599 endfunc
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
600
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
601 " Test for errors in using complete() function
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
602 func Test_complete_func_error()
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
603 call assert_fails('call complete(1, ["a"])', 'E785:')
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
604 func ListColors()
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
605 call complete(col('.'), "blue")
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
606 endfunc
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
607 call assert_fails('exe "normal i\<C-R>=ListColors()\<CR>"', 'E474:')
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
608 func ListMonths()
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
609 call complete(col('.'), test_null_list())
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
610 endfunc
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
611 call assert_fails('exe "normal i\<C-R>=ListMonths()\<CR>"', 'E474:')
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
612 delfunc ListColors
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
613 delfunc ListMonths
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
614 call assert_fails('call complete_info({})', 'E714:')
20285
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
615 call assert_equal([], complete_info(['items']).items)
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
616 endfunc
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
617
20199
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
618 " Test for completing words following a completed word in a line
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
619 func Test_complete_wrapscan()
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
620 " complete words from another buffer
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
621 new
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
622 call setline(1, ['one two', 'three four'])
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
623 new
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
624 setlocal complete=w
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
625 call feedkeys("itw\<C-N>\<C-X>\<C-N>\<C-X>\<C-N>\<C-X>\<C-N>", 'xt')
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
626 call assert_equal('two three four', getline(1))
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
627 close!
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
628 " complete words from the current buffer
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
629 setlocal complete=.
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
630 %d
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
631 call setline(1, ['one two', ''])
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
632 call cursor(2, 1)
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
633 call feedkeys("ion\<C-N>\<C-X>\<C-N>\<C-X>\<C-N>\<C-X>\<C-N>", 'xt')
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
634 call assert_equal('one two one two', getline(2))
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
635 close!
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
636 endfunc
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
637
20285
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
638 " Test for completing special characters
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
639 func Test_complete_special_chars()
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
640 new
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
641 call setline(1, 'int .*[-\^$ func float')
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
642 call feedkeys("oin\<C-X>\<C-P>\<C-X>\<C-P>\<C-X>\<C-P>", 'xt')
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
643 call assert_equal('int .*[-\^$ func float', getline(2))
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
644 close!
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
645 endfunc
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
646
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
647 " Test for completion when text is wrapped across lines.
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
648 func Test_complete_across_line()
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
649 new
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
650 call setline(1, ['red green blue', 'one two three'])
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
651 setlocal textwidth=20
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
652 exe "normal 2G$a re\<C-X>\<C-P>\<C-X>\<C-P>\<C-X>\<C-P>\<C-X>\<C-P>"
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
653 call assert_equal(['one two three red', 'green blue one'], getline(2, '$'))
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
654 close!
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
655 endfunc
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
656
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
657 " Test for using CTRL-L to add one character when completing matching
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
658 func Test_complete_add_onechar()
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
659 new
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
660 call setline(1, ['wool', 'woodwork'])
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
661 call feedkeys("Gowoo\<C-P>\<C-P>\<C-P>\<C-L>f", 'xt')
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
662 call assert_equal('woof', getline(3))
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
663
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
664 " use 'ignorecase' and backspace to erase characters from the prefix string
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
665 " and then add letters using CTRL-L
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
666 %d
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
667 set ignorecase backspace=2
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
668 setlocal complete=.
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
669 call setline(1, ['workhorse', 'workload'])
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
670 normal Go
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
671 exe "normal aWOR\<C-P>\<bs>\<bs>\<bs>\<bs>\<bs>\<bs>\<C-L>r\<C-L>\<C-L>"
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
672 call assert_equal('workh', getline(3))
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
673 set ignorecase& backspace&
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
674 close!
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
675 endfunc
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
676
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
677 " Test insert completion with 'cindent' (adjust the indent)
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
678 func Test_complete_with_cindent()
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
679 new
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
680 setlocal cindent
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
681 call setline(1, ['if (i == 1)', " j = 2;"])
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
682 exe "normal Go{\<CR>i\<C-X>\<C-L>\<C-X>\<C-L>\<CR>}"
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
683 call assert_equal(['{', "\tif (i == 1)", "\t\tj = 2;", '}'], getline(3, '$'))
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
684
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
685 %d
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
686 call setline(1, ['when while', '{', ''])
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
687 setlocal cinkeys+==while
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
688 exe "normal Giwh\<C-P> "
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
689 call assert_equal("\twhile ", getline('$'))
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
690 close!
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
691 endfunc
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
692
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
693 " Test for <CTRL-X> <CTRL-V> completion. Complete commands and functions
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
694 func Test_complete_cmdline()
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
695 new
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
696 exe "normal icaddb\<C-X>\<C-V>"
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
697 call assert_equal('caddbuffer', getline(1))
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
698 exe "normal ocall getqf\<C-X>\<C-V>"
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
699 call assert_equal('call getqflist(', getline(2))
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
700 exe "normal oabcxyz(\<C-X>\<C-V>"
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
701 call assert_equal('abcxyz(', getline(3))
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
702 close!
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
703 endfunc
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
704
22397
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22248
diff changeset
705 func Test_issue_7021()
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22248
diff changeset
706 CheckMSWindows
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22248
diff changeset
707
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22248
diff changeset
708 let orig_shellslash = &shellslash
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22248
diff changeset
709 set noshellslash
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22248
diff changeset
710
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22248
diff changeset
711 set completeslash=slash
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22248
diff changeset
712 call assert_false(expand('~') =~ '/')
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22248
diff changeset
713
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22248
diff changeset
714 let &shellslash = orig_shellslash
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22248
diff changeset
715 set completeslash=
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22248
diff changeset
716 endfunc
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22248
diff changeset
717
23169
5e6855ebc4ea patch 8.2.2130: Insert mode completion messages end up in message history
Bram Moolenaar <Bram@vim.org>
parents: 22717
diff changeset
718 " Test to ensure 'Scanning...' messages are not recorded in messages history
5e6855ebc4ea patch 8.2.2130: Insert mode completion messages end up in message history
Bram Moolenaar <Bram@vim.org>
parents: 22717
diff changeset
719 func Test_z1_complete_no_history()
5e6855ebc4ea patch 8.2.2130: Insert mode completion messages end up in message history
Bram Moolenaar <Bram@vim.org>
parents: 22717
diff changeset
720 new
5e6855ebc4ea patch 8.2.2130: Insert mode completion messages end up in message history
Bram Moolenaar <Bram@vim.org>
parents: 22717
diff changeset
721 messages clear
5e6855ebc4ea patch 8.2.2130: Insert mode completion messages end up in message history
Bram Moolenaar <Bram@vim.org>
parents: 22717
diff changeset
722 let currmess = execute('messages')
5e6855ebc4ea patch 8.2.2130: Insert mode completion messages end up in message history
Bram Moolenaar <Bram@vim.org>
parents: 22717
diff changeset
723 setlocal dictionary=README.txt
5e6855ebc4ea patch 8.2.2130: Insert mode completion messages end up in message history
Bram Moolenaar <Bram@vim.org>
parents: 22717
diff changeset
724 exe "normal owh\<C-X>\<C-K>"
5e6855ebc4ea patch 8.2.2130: Insert mode completion messages end up in message history
Bram Moolenaar <Bram@vim.org>
parents: 22717
diff changeset
725 exe "normal owh\<C-N>"
5e6855ebc4ea patch 8.2.2130: Insert mode completion messages end up in message history
Bram Moolenaar <Bram@vim.org>
parents: 22717
diff changeset
726 call assert_equal(currmess, execute('messages'))
5e6855ebc4ea patch 8.2.2130: Insert mode completion messages end up in message history
Bram Moolenaar <Bram@vim.org>
parents: 22717
diff changeset
727 close!
5e6855ebc4ea patch 8.2.2130: Insert mode completion messages end up in message history
Bram Moolenaar <Bram@vim.org>
parents: 22717
diff changeset
728 endfunc
5e6855ebc4ea patch 8.2.2130: Insert mode completion messages end up in message history
Bram Moolenaar <Bram@vim.org>
parents: 22717
diff changeset
729
19932
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19651
diff changeset
730 " vim: shiftwidth=2 sts=2 expandtab