annotate src/testdir/test_ins_complete.vim @ 35405:9a52a7b13fc5 v9.1.0484

patch 9.1.0484: Sorting of completeopt+=fuzzy is not stable Commit: https://github.com/vim/vim/commit/8e56747fd26b3b040b6fcbfb6be41b7d5922c6b5 Author: zeertzjq <zeertzjq@outlook.com> Date: Fri Jun 14 20:04:42 2024 +0200 patch 9.1.0484: Sorting of completeopt+=fuzzy is not stable Problem: Sorting of completeopt+=fuzzy is not stable. Solution: Compare original indexes when scores are the same. (zeertzjq) closes: #14988 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Fri, 14 Jun 2024 20:15:06 +0200
parents 5c4e1b16db10
children 3f686877921c
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
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27016
diff changeset
5 import './vim9.vim' as v9
12686
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 " Test for insert expansion
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 func Test_ins_complete()
12692
03a6aeea2096 patch 8.0.1224: still interference between test functions
Christian Brabandt <cb@256bit.org>
parents: 12686
diff changeset
9 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
10 " 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
11 " used by this test. So use a separate directory for the test.
29970
d891115c0aea patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents: 29554
diff changeset
12 call mkdir('Xcpldir')
d891115c0aea patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents: 29554
diff changeset
13 cd Xcpldir
12788
cb9b2774f21f patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents: 12728
diff changeset
14
12686
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 set ff=unix
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 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
17 \ "asd\ttest11file\t36G",
30580
f08ed0738f7a patch 9.0.0625: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30487
diff changeset
18 \ "Makefile\tto\trun"], 'Xtestfile', 'D')
12686
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 call writefile(['', 'start of testfile',
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 \ 'ru',
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 \ 'run1',
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 \ 'run2',
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 \ 'STARTTEST',
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 \ 'ENDTEST',
30580
f08ed0738f7a patch 9.0.0625: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30487
diff changeset
25 \ 'end of testfile'], 'Xtestdata', 'D')
12686
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 set ff&
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 enew!
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 edit Xtestdata
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 new
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 call append(0, ['#include "Xtestfile"', ''])
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 call cursor(2, 1)
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 set cot=
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 set cpt=.,w
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36 " 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
37 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
38 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
39 " add-expands (current buffer first)
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 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
41 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
42 " 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
43 " expansion)
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 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
45 call assert_equal('', getline('.'))
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 " 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
47 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
48 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
49
26817
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
50 set cpt=.,\ ,w,i
12686
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 " 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
52 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
53 call assert_equal("Makefile\tto\trun3", getline('.'))
26211
485c7c4afeb7 patch 8.2.3637: typos in test files
Bram Moolenaar <Bram@vim.org>
parents: 26195
diff changeset
54 " add-expands lines (it would end in an empty line if it didn't ignore
12686
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 " itself)
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 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
57 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
58 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
59
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 set cpt=kXtestfile
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 " 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
62 " 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
63 write Xtest11.one
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 write Xtest11.two
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 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
66 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
67
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 " 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
69 " 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
70 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
71 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
72 normal ddk
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73
27016
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
74 " Test for expanding a non-existing filename
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
75 exe "normal oa1b2X3Y4\<C-X>\<C-F>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
76 call assert_equal('a1b2X3Y4', getline('.'))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
77 normal ddk
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
78
12686
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 set cpt=w
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 " 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
81 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
82 call assert_equal('STARTTEST', getline('.'))
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 set cpt=u nohid
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 " checks unloaded buffer expansion
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86 only
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 exe "normal oEN\<C-N>"
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 call assert_equal('ENDTEST', getline('.'))
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89 " checks adding mode abortion
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
90 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
91 call assert_equal('unless', getline('.'))
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
92
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
93 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
94 " 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
95 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
96 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
97 " t-expansion
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
98 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
99 call assert_equal('asd', getline('.'))
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
100
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
101 %bw!
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
102 call delete('Xtest11.one')
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
103 call delete('Xtest11.two')
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
104 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
105 cd ..
29970
d891115c0aea patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents: 29554
diff changeset
106 call delete('Xcpldir', 'rf')
12686
aa658b33f25a patch 8.0.1221: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
107 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
108
26773
80e134cbee4b patch 8.2.3915: illegal memory access when completing with invalid bytes
Bram Moolenaar <Bram@vim.org>
parents: 26618
diff changeset
109 func Test_ins_complete_invalid_byte()
80e134cbee4b patch 8.2.3915: illegal memory access when completing with invalid bytes
Bram Moolenaar <Bram@vim.org>
parents: 26618
diff changeset
110 if has('unix') && executable('base64')
80e134cbee4b patch 8.2.3915: illegal memory access when completing with invalid bytes
Bram Moolenaar <Bram@vim.org>
parents: 26618
diff changeset
111 " this weird command was causing an illegal memory access
30580
f08ed0738f7a patch 9.0.0625: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30487
diff changeset
112 call writefile(['bm9ybTlvMDCAMM4Dbw4OGA4ODg=='], 'Xinvalid64', 'D')
26773
80e134cbee4b patch 8.2.3915: illegal memory access when completing with invalid bytes
Bram Moolenaar <Bram@vim.org>
parents: 26618
diff changeset
113 call system('base64 -d Xinvalid64 > Xinvalid')
30580
f08ed0738f7a patch 9.0.0625: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30487
diff changeset
114 call writefile(['qa!'], 'Xexit', 'D')
26773
80e134cbee4b patch 8.2.3915: illegal memory access when completing with invalid bytes
Bram Moolenaar <Bram@vim.org>
parents: 26618
diff changeset
115 call RunVim([], [], " -i NONE -n -X -Z -e -m -s -S Xinvalid -S Xexit")
80e134cbee4b patch 8.2.3915: illegal memory access when completing with invalid bytes
Bram Moolenaar <Bram@vim.org>
parents: 26618
diff changeset
116 call delete('Xinvalid')
80e134cbee4b patch 8.2.3915: illegal memory access when completing with invalid bytes
Bram Moolenaar <Bram@vim.org>
parents: 26618
diff changeset
117 endif
80e134cbee4b patch 8.2.3915: illegal memory access when completing with invalid bytes
Bram Moolenaar <Bram@vim.org>
parents: 26618
diff changeset
118 endfunc
80e134cbee4b patch 8.2.3915: illegal memory access when completing with invalid bytes
Bram Moolenaar <Bram@vim.org>
parents: 26618
diff changeset
119
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
120 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
121 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
122 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
123 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
124 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
125 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
126 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
127 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
128 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
129 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
130 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
131 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
132 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
133
9c1659761fc3 patch 8.0.1242: function argument with only dash is seen as number zero
Christian Brabandt <cb@256bit.org>
parents: 12692
diff changeset
134 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
135 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
136 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
137 endfunc
13215
ae5f855a64be patch 8.0.1482: using feedkeys() does not work to test completion
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
138
29000
7d28903e80df patch 8.2.5022: 'completefunc'/'omnifunc' error does not end completion
Bram Moolenaar <Bram@vim.org>
parents: 28682
diff changeset
139 func Test_omni_throw()
7d28903e80df patch 8.2.5022: 'completefunc'/'omnifunc' error does not end completion
Bram Moolenaar <Bram@vim.org>
parents: 28682
diff changeset
140 let g:CallCount = 0
7d28903e80df patch 8.2.5022: 'completefunc'/'omnifunc' error does not end completion
Bram Moolenaar <Bram@vim.org>
parents: 28682
diff changeset
141 func Omni(findstart, base)
7d28903e80df patch 8.2.5022: 'completefunc'/'omnifunc' error does not end completion
Bram Moolenaar <Bram@vim.org>
parents: 28682
diff changeset
142 let g:CallCount += 1
7d28903e80df patch 8.2.5022: 'completefunc'/'omnifunc' error does not end completion
Bram Moolenaar <Bram@vim.org>
parents: 28682
diff changeset
143 if a:findstart
7d28903e80df patch 8.2.5022: 'completefunc'/'omnifunc' error does not end completion
Bram Moolenaar <Bram@vim.org>
parents: 28682
diff changeset
144 throw "he he he"
7d28903e80df patch 8.2.5022: 'completefunc'/'omnifunc' error does not end completion
Bram Moolenaar <Bram@vim.org>
parents: 28682
diff changeset
145 endif
7d28903e80df patch 8.2.5022: 'completefunc'/'omnifunc' error does not end completion
Bram Moolenaar <Bram@vim.org>
parents: 28682
diff changeset
146 endfunc
7d28903e80df patch 8.2.5022: 'completefunc'/'omnifunc' error does not end completion
Bram Moolenaar <Bram@vim.org>
parents: 28682
diff changeset
147 set omnifunc=Omni
7d28903e80df patch 8.2.5022: 'completefunc'/'omnifunc' error does not end completion
Bram Moolenaar <Bram@vim.org>
parents: 28682
diff changeset
148 new
7d28903e80df patch 8.2.5022: 'completefunc'/'omnifunc' error does not end completion
Bram Moolenaar <Bram@vim.org>
parents: 28682
diff changeset
149 try
7d28903e80df patch 8.2.5022: 'completefunc'/'omnifunc' error does not end completion
Bram Moolenaar <Bram@vim.org>
parents: 28682
diff changeset
150 exe "normal ifoo\<C-x>\<C-o>"
7d28903e80df patch 8.2.5022: 'completefunc'/'omnifunc' error does not end completion
Bram Moolenaar <Bram@vim.org>
parents: 28682
diff changeset
151 call assert_false(v:true, 'command should have failed')
7d28903e80df patch 8.2.5022: 'completefunc'/'omnifunc' error does not end completion
Bram Moolenaar <Bram@vim.org>
parents: 28682
diff changeset
152 catch
7d28903e80df patch 8.2.5022: 'completefunc'/'omnifunc' error does not end completion
Bram Moolenaar <Bram@vim.org>
parents: 28682
diff changeset
153 call assert_exception('he he he')
7d28903e80df patch 8.2.5022: 'completefunc'/'omnifunc' error does not end completion
Bram Moolenaar <Bram@vim.org>
parents: 28682
diff changeset
154 call assert_equal(1, g:CallCount)
7d28903e80df patch 8.2.5022: 'completefunc'/'omnifunc' error does not end completion
Bram Moolenaar <Bram@vim.org>
parents: 28682
diff changeset
155 endtry
7d28903e80df patch 8.2.5022: 'completefunc'/'omnifunc' error does not end completion
Bram Moolenaar <Bram@vim.org>
parents: 28682
diff changeset
156
7d28903e80df patch 8.2.5022: 'completefunc'/'omnifunc' error does not end completion
Bram Moolenaar <Bram@vim.org>
parents: 28682
diff changeset
157 bwipe!
7d28903e80df patch 8.2.5022: 'completefunc'/'omnifunc' error does not end completion
Bram Moolenaar <Bram@vim.org>
parents: 28682
diff changeset
158 delfunc Omni
7d28903e80df patch 8.2.5022: 'completefunc'/'omnifunc' error does not end completion
Bram Moolenaar <Bram@vim.org>
parents: 28682
diff changeset
159 unlet g:CallCount
7d28903e80df patch 8.2.5022: 'completefunc'/'omnifunc' error does not end completion
Bram Moolenaar <Bram@vim.org>
parents: 28682
diff changeset
160 set omnifunc=
7d28903e80df patch 8.2.5022: 'completefunc'/'omnifunc' error does not end completion
Bram Moolenaar <Bram@vim.org>
parents: 28682
diff changeset
161 endfunc
7d28903e80df patch 8.2.5022: 'completefunc'/'omnifunc' error does not end completion
Bram Moolenaar <Bram@vim.org>
parents: 28682
diff changeset
162
25372
c63a2d24b7e2 patch 8.2.3223: Vim: using {} block in autoloade omnifunc fails
Bram Moolenaar <Bram@vim.org>
parents: 23772
diff changeset
163 func Test_omni_autoload()
c63a2d24b7e2 patch 8.2.3223: Vim: using {} block in autoloade omnifunc fails
Bram Moolenaar <Bram@vim.org>
parents: 23772
diff changeset
164 let save_rtp = &rtp
c63a2d24b7e2 patch 8.2.3223: Vim: using {} block in autoloade omnifunc fails
Bram Moolenaar <Bram@vim.org>
parents: 23772
diff changeset
165 set rtp=Xruntime/some
c63a2d24b7e2 patch 8.2.3223: Vim: using {} block in autoloade omnifunc fails
Bram Moolenaar <Bram@vim.org>
parents: 23772
diff changeset
166 let dir = 'Xruntime/some/autoload'
30580
f08ed0738f7a patch 9.0.0625: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30487
diff changeset
167 call mkdir(dir, 'pR')
25372
c63a2d24b7e2 patch 8.2.3223: Vim: using {} block in autoloade omnifunc fails
Bram Moolenaar <Bram@vim.org>
parents: 23772
diff changeset
168
c63a2d24b7e2 patch 8.2.3223: Vim: using {} block in autoloade omnifunc fails
Bram Moolenaar <Bram@vim.org>
parents: 23772
diff changeset
169 let lines =<< trim END
c63a2d24b7e2 patch 8.2.3223: Vim: using {} block in autoloade omnifunc fails
Bram Moolenaar <Bram@vim.org>
parents: 23772
diff changeset
170 vim9script
27474
307341b9c227 patch 8.2.4265: autoload tests fails
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
171 export def Func(findstart: bool, base: string): any
25372
c63a2d24b7e2 patch 8.2.3223: Vim: using {} block in autoloade omnifunc fails
Bram Moolenaar <Bram@vim.org>
parents: 23772
diff changeset
172 if findstart
c63a2d24b7e2 patch 8.2.3223: Vim: using {} block in autoloade omnifunc fails
Bram Moolenaar <Bram@vim.org>
parents: 23772
diff changeset
173 return 1
c63a2d24b7e2 patch 8.2.3223: Vim: using {} block in autoloade omnifunc fails
Bram Moolenaar <Bram@vim.org>
parents: 23772
diff changeset
174 else
c63a2d24b7e2 patch 8.2.3223: Vim: using {} block in autoloade omnifunc fails
Bram Moolenaar <Bram@vim.org>
parents: 23772
diff changeset
175 return ['match']
c63a2d24b7e2 patch 8.2.3223: Vim: using {} block in autoloade omnifunc fails
Bram Moolenaar <Bram@vim.org>
parents: 23772
diff changeset
176 endif
c63a2d24b7e2 patch 8.2.3223: Vim: using {} block in autoloade omnifunc fails
Bram Moolenaar <Bram@vim.org>
parents: 23772
diff changeset
177 enddef
c63a2d24b7e2 patch 8.2.3223: Vim: using {} block in autoloade omnifunc fails
Bram Moolenaar <Bram@vim.org>
parents: 23772
diff changeset
178 {
c63a2d24b7e2 patch 8.2.3223: Vim: using {} block in autoloade omnifunc fails
Bram Moolenaar <Bram@vim.org>
parents: 23772
diff changeset
179 eval 1 + 2
c63a2d24b7e2 patch 8.2.3223: Vim: using {} block in autoloade omnifunc fails
Bram Moolenaar <Bram@vim.org>
parents: 23772
diff changeset
180 }
c63a2d24b7e2 patch 8.2.3223: Vim: using {} block in autoloade omnifunc fails
Bram Moolenaar <Bram@vim.org>
parents: 23772
diff changeset
181 END
c63a2d24b7e2 patch 8.2.3223: Vim: using {} block in autoloade omnifunc fails
Bram Moolenaar <Bram@vim.org>
parents: 23772
diff changeset
182 call writefile(lines, dir .. '/omni.vim')
c63a2d24b7e2 patch 8.2.3223: Vim: using {} block in autoloade omnifunc fails
Bram Moolenaar <Bram@vim.org>
parents: 23772
diff changeset
183
c63a2d24b7e2 patch 8.2.3223: Vim: using {} block in autoloade omnifunc fails
Bram Moolenaar <Bram@vim.org>
parents: 23772
diff changeset
184 new
27474
307341b9c227 patch 8.2.4265: autoload tests fails
Bram Moolenaar <Bram@vim.org>
parents: 27464
diff changeset
185 setlocal omnifunc=omni#Func
25372
c63a2d24b7e2 patch 8.2.3223: Vim: using {} block in autoloade omnifunc fails
Bram Moolenaar <Bram@vim.org>
parents: 23772
diff changeset
186 call feedkeys("i\<C-X>\<C-O>\<Esc>", 'xt')
c63a2d24b7e2 patch 8.2.3223: Vim: using {} block in autoloade omnifunc fails
Bram Moolenaar <Bram@vim.org>
parents: 23772
diff changeset
187
c63a2d24b7e2 patch 8.2.3223: Vim: using {} block in autoloade omnifunc fails
Bram Moolenaar <Bram@vim.org>
parents: 23772
diff changeset
188 bwipe!
c63a2d24b7e2 patch 8.2.3223: Vim: using {} block in autoloade omnifunc fails
Bram Moolenaar <Bram@vim.org>
parents: 23772
diff changeset
189 set omnifunc=
c63a2d24b7e2 patch 8.2.3223: Vim: using {} block in autoloade omnifunc fails
Bram Moolenaar <Bram@vim.org>
parents: 23772
diff changeset
190 let &rtp = save_rtp
c63a2d24b7e2 patch 8.2.3223: Vim: using {} block in autoloade omnifunc fails
Bram Moolenaar <Bram@vim.org>
parents: 23772
diff changeset
191 endfunc
c63a2d24b7e2 patch 8.2.3223: Vim: using {} block in autoloade omnifunc fails
Bram Moolenaar <Bram@vim.org>
parents: 23772
diff changeset
192
14071
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
193 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
194 let s:args = []
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
195 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
196 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
197 endfunc
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
198 new
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
199
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
200 set completefunc=CompleteFunc
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
201 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
202 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
203 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
204 set completefunc=
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
205
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
206 let s:args = []
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
207 set omnifunc=CompleteFunc
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
208 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
209 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
210 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
211 set omnifunc=
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
212
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
213 bwipe!
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
214 unlet s:args
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
215 delfunc CompleteFunc
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
216 endfunc
c1fcfafa8d1a patch 8.1.0053: first argument of 'completefunc' has inconsistent type
Christian Brabandt <cb@256bit.org>
parents: 13238
diff changeset
217
15416
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
218 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
219 if a:findstart
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
220 return 0
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
221 endif
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
222
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
223 return v:none
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
224 endfunc
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
225
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 14489
diff changeset
226 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
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',
31459
09fe45711621 patch 9.0.1062: some test function names do not match what they are doing
Bram Moolenaar <Bram@vim.org>
parents: 30580
diff changeset
239 \ 'user_data': ['one', 'two']
19047
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
15416
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
245 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
246 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
247 endfunc
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
248
19199
8cbadf7fb9d4 patch 8.2.0158: triggering CompleteDone earlier is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 19127
diff changeset
249 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
250 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
251 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
252 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
253 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
254 call assert_equal( 'W', v:completed_item[ 'kind' ] )
31459
09fe45711621 patch 9.0.1062: some test function names do not match what they are doing
Bram Moolenaar <Bram@vim.org>
parents: 30580
diff changeset
255 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
256
19199
8cbadf7fb9d4 patch 8.2.0158: triggering CompleteDone earlier is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 19127
diff changeset
257 if a:pre
8cbadf7fb9d4 patch 8.2.0158: triggering CompleteDone earlier is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 19127
diff changeset
258 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
259 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
260
13238
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
261 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
262 endfunc
13238
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
263
15416
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
264 func Test_CompleteDoneNone()
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
265 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
266 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
267
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
268 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
269 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
270 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
271 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
272
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
273 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
274 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
275
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
276 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
277 au! CompleteDone
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
278 endfunc
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
279
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
280 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
281 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
282 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
283
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
284 set completefunc=<SID>CompleteDone_CompleteFuncDict
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
285 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
286 set completefunc&
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
287
31459
09fe45711621 patch 9.0.1062: some test function names do not match what they are doing
Bram Moolenaar <Bram@vim.org>
parents: 30580
diff changeset
288 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
289 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
290
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
291 let s:called_completedone = 0
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
292 au! CompleteDone
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
293 endfunc
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
294
15416
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
295 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
296 if a:findstart
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
297 return 0
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
298 endif
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
299
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
300 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
301 \ 'words': [
a3fce2763e83 patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents: 18900
diff changeset
302 \ {
a3fce2763e83 patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents: 18900
diff changeset
303 \ '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
304 \ '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
305 \ '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
306 \ '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
307 \ '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
308 \ }
a3fce2763e83 patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents: 18900
diff changeset
309 \ ]
a3fce2763e83 patch 8.2.0084: complete item "user_data" can only be a string
Bram Moolenaar <Bram@vim.org>
parents: 18900
diff changeset
310 \ }
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 14489
diff changeset
311 endfunc
13238
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
312
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 14489
diff changeset
313 func s:CompleteDone_CheckCompletedItemDictNoUserData()
13238
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
314 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
315 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
316 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
317 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
318 call assert_equal( 'W', v:completed_item[ 'kind' ] )
31459
09fe45711621 patch 9.0.1062: some test function names do not match what they are doing
Bram Moolenaar <Bram@vim.org>
parents: 30580
diff changeset
319 call assert_equal( '', 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
320
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
321 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
322 endfunc
13238
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
323
15416
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
324 func Test_CompleteDoneDictNoUserData()
13238
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
325 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
326
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
327 set completefunc=<SID>CompleteDone_CompleteFuncDictNoUserData
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
328 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
329 set completefunc&
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
330
31459
09fe45711621 patch 9.0.1062: some test function names do not match what they are doing
Bram Moolenaar <Bram@vim.org>
parents: 30580
diff changeset
331 call assert_equal('', 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
332 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
333
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
334 let s:called_completedone = 0
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
335 au! CompleteDone
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
336 endfunc
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
337
15416
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
338 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
339 if a:findstart
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
340 return 0
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
341 endif
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
342
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
343 return [ 'aword' ]
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 14489
diff changeset
344 endfunc
13238
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
345
15406
63b02fcf1361 patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents: 14489
diff changeset
346 func s:CompleteDone_CheckCompletedItemList()
13238
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
347 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
348 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
349 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
350 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
351 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
352 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
353
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
354 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
355 endfunc
13238
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
356
15416
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
357 func Test_CompleteDoneList()
13238
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
358 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
359
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
360 set completefunc=<SID>CompleteDone_CompleteFuncList
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
361 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
362 set completefunc&
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
363
15416
5f8ddd2a7b92 patch 8.1.0716: get warning message when 'completefunc' returns nothing
Bram Moolenaar <Bram@vim.org>
parents: 15406
diff changeset
364 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
365 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
366
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
367 let s:called_completedone = 0
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
368 au! CompleteDone
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
369 endfunc
e0dcfd3dbb52 patch 8.0.1493: completion items cannot be annotated
Christian Brabandt <cb@256bit.org>
parents: 13215
diff changeset
370
14489
cda216729f9b patch 8.1.0258: not enough testing for the CompleteDone event
Christian Brabandt <cb@256bit.org>
parents: 14075
diff changeset
371 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
372 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
373 new
cda216729f9b patch 8.1.0258: not enough testing for the CompleteDone event
Christian Brabandt <cb@256bit.org>
parents: 14075
diff changeset
374 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
375 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
376 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
377 \ getline(1, '$'))
cda216729f9b patch 8.1.0258: not enough testing for the CompleteDone event
Christian Brabandt <cb@256bit.org>
parents: 14075
diff changeset
378 undo
cda216729f9b patch 8.1.0258: not enough testing for the CompleteDone event
Christian Brabandt <cb@256bit.org>
parents: 14075
diff changeset
379 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
380 bwipe!
cda216729f9b patch 8.1.0258: not enough testing for the CompleteDone event
Christian Brabandt <cb@256bit.org>
parents: 14075
diff changeset
381 au! CompleteDone
cda216729f9b patch 8.1.0258: not enough testing for the CompleteDone event
Christian Brabandt <cb@256bit.org>
parents: 14075
diff changeset
382 endfunc
cda216729f9b patch 8.1.0258: not enough testing for the CompleteDone event
Christian Brabandt <cb@256bit.org>
parents: 14075
diff changeset
383
29501
69d24e60f4f8 patch 9.0.0092: plugins cannot change v:completed_item
Bram Moolenaar <Bram@vim.org>
parents: 29436
diff changeset
384 func Test_CompleteDone_modify()
69d24e60f4f8 patch 9.0.0092: plugins cannot change v:completed_item
Bram Moolenaar <Bram@vim.org>
parents: 29436
diff changeset
385 let value = {
69d24e60f4f8 patch 9.0.0092: plugins cannot change v:completed_item
Bram Moolenaar <Bram@vim.org>
parents: 29436
diff changeset
386 \ 'word': '',
69d24e60f4f8 patch 9.0.0092: plugins cannot change v:completed_item
Bram Moolenaar <Bram@vim.org>
parents: 29436
diff changeset
387 \ 'abbr': '',
69d24e60f4f8 patch 9.0.0092: plugins cannot change v:completed_item
Bram Moolenaar <Bram@vim.org>
parents: 29436
diff changeset
388 \ 'menu': '',
69d24e60f4f8 patch 9.0.0092: plugins cannot change v:completed_item
Bram Moolenaar <Bram@vim.org>
parents: 29436
diff changeset
389 \ 'info': '',
69d24e60f4f8 patch 9.0.0092: plugins cannot change v:completed_item
Bram Moolenaar <Bram@vim.org>
parents: 29436
diff changeset
390 \ 'kind': '',
69d24e60f4f8 patch 9.0.0092: plugins cannot change v:completed_item
Bram Moolenaar <Bram@vim.org>
parents: 29436
diff changeset
391 \ 'user_data': '',
69d24e60f4f8 patch 9.0.0092: plugins cannot change v:completed_item
Bram Moolenaar <Bram@vim.org>
parents: 29436
diff changeset
392 \ }
69d24e60f4f8 patch 9.0.0092: plugins cannot change v:completed_item
Bram Moolenaar <Bram@vim.org>
parents: 29436
diff changeset
393 let v:completed_item = value
29554
d413dccd4f8a patch 9.0.0118: no test for what patch 9.0.0155 fixes
Bram Moolenaar <Bram@vim.org>
parents: 29521
diff changeset
394 call assert_equal(value, v:completed_item)
29501
69d24e60f4f8 patch 9.0.0092: plugins cannot change v:completed_item
Bram Moolenaar <Bram@vim.org>
parents: 29436
diff changeset
395 endfunc
69d24e60f4f8 patch 9.0.0092: plugins cannot change v:completed_item
Bram Moolenaar <Bram@vim.org>
parents: 29436
diff changeset
396
22248
80a000b09cb0 patch 8.2.1673: complete_info() selected index has an invalid value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
397 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
398 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
399 return col('.')
80a000b09cb0 patch 8.2.1673: complete_info() selected index has an invalid value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
400 endif
80a000b09cb0 patch 8.2.1673: complete_info() selected index has an invalid value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
401 return ['matched']
80a000b09cb0 patch 8.2.1673: complete_info() selected index has an invalid value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
402 endfunc
80a000b09cb0 patch 8.2.1673: complete_info() selected index has an invalid value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
403
80a000b09cb0 patch 8.2.1673: complete_info() selected index has an invalid value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
404 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
405 new
80a000b09cb0 patch 8.2.1673: complete_info() selected index has an invalid value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
406 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
407 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
408 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
409 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
410 bwipe!
80a000b09cb0 patch 8.2.1673: complete_info() selected index has an invalid value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
411 set completeopt&
80a000b09cb0 patch 8.2.1673: complete_info() selected index has an invalid value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
412 set completefunc&
80a000b09cb0 patch 8.2.1673: complete_info() selected index has an invalid value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
413 endfunc
80a000b09cb0 patch 8.2.1673: complete_info() selected index has an invalid value
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
414
34596
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
415 func CompleteInfoUserDefinedFn(findstart, query)
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
416 " User defined function (i_CTRL-X_CTRL-U)
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
417 if a:findstart
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
418 return col('.')
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
419 endif
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
420 return [{'word': 'foo'}, {'word': 'bar'}, {'word': 'baz'}, {'word': 'qux'}]
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
421 endfunc
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
422
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
423 func CompleteInfoTestUserDefinedFn(mvmt, idx, noselect)
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
424 new
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
425 if a:noselect
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
426 set completeopt=menuone,popup,noinsert,noselect
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
427 else
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
428 set completeopt=menu,preview
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
429 endif
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
430 set completefunc=CompleteInfoUserDefinedFn
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
431 call feedkeys("i\<C-X>\<C-U>" . a:mvmt . "\<C-R>\<C-R>=string(complete_info())\<CR>\<ESC>", "tx")
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
432 let completed = a:idx != -1 ? ['foo', 'bar', 'baz', 'qux']->get(a:idx) : ''
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
433 call assert_equal(completed. "{'pum_visible': 1, 'mode': 'function', 'selected': " . a:idx . ", 'items': [" .
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
434 \ "{'word': 'foo', 'menu': '', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''}, " .
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
435 \ "{'word': 'bar', 'menu': '', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''}, " .
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
436 \ "{'word': 'baz', 'menu': '', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''}, " .
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
437 \ "{'word': 'qux', 'menu': '', 'user_data': '', 'info': '', 'kind': '', 'abbr': ''}" .
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
438 \ "]}", getline(1))
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
439 bwipe!
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
440 set completeopt&
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
441 set completefunc&
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
442 endfunc
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
443
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
444 func Test_complete_info_user_defined_fn()
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
445 " forward
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
446 call CompleteInfoTestUserDefinedFn("\<C-N>\<C-N>", 1, v:true)
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
447 call CompleteInfoTestUserDefinedFn("\<C-N>\<C-N>\<C-N>", 2, v:true)
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
448 call CompleteInfoTestUserDefinedFn("\<C-N>\<C-N>", 2, v:false)
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
449 call CompleteInfoTestUserDefinedFn("\<C-N>\<C-N>\<C-N>", 3, v:false)
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
450 call CompleteInfoTestUserDefinedFn("\<C-N>\<C-N>\<C-N>\<C-N>", -1, v:false)
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
451 " backward
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
452 call CompleteInfoTestUserDefinedFn("\<C-P>\<C-P>", 2, v:true)
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
453 call CompleteInfoTestUserDefinedFn("\<C-P>\<C-P>\<C-P>", 1, v:true)
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
454 call CompleteInfoTestUserDefinedFn("\<C-P>\<C-P>\<C-P>\<C-P>\<C-P>", -1, v:true)
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
455 call CompleteInfoTestUserDefinedFn("\<C-P>\<C-P>", 3, v:false)
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
456 call CompleteInfoTestUserDefinedFn("\<C-P>\<C-P>\<C-P>", 2, v:false)
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
457 " forward backward
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
458 call CompleteInfoTestUserDefinedFn("\<C-N>\<C-N>\<C-N>\<C-P>", 1, v:true)
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
459 call CompleteInfoTestUserDefinedFn("\<C-N>\<C-N>\<C-P>", 0, v:true)
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
460 call CompleteInfoTestUserDefinedFn("\<C-N>\<C-N>\<C-N>\<C-P>", 2, v:false)
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
461 call CompleteInfoTestUserDefinedFn("\<C-N>\<C-N>\<C-N>\<C-N>\<C-P>", 3, v:false)
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
462 call CompleteInfoTestUserDefinedFn("\<C-N>\<C-N>\<C-P>", 1, v:false)
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
463 " backward forward
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
464 call CompleteInfoTestUserDefinedFn("\<C-P>\<C-P>\<C-P>\<C-P>\<C-P>\<C-N>", 0, v:true)
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
465 call CompleteInfoTestUserDefinedFn("\<C-P>\<C-P>\<C-P>\<C-N>", 2, v:true)
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
466 call CompleteInfoTestUserDefinedFn("\<C-P>\<C-P>\<C-P>\<C-P>\<C-P>\<C-N>", 1, v:false)
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
467 call CompleteInfoTestUserDefinedFn("\<C-P>\<C-P>\<C-P>\<C-N>", 3, v:false)
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
468 call CompleteInfoTestUserDefinedFn("\<C-P>\<C-N>\<C-N>", 1, v:false)
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
469 endfunc
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
470
32080
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
471 " Test that mouse scrolling/movement should not interrupt completion.
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
472 func Test_mouse_scroll_move_during_completion()
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
473 new
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
474 com! -buffer TestCommand1 echo 'TestCommand1'
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
475 com! -buffer TestCommand2 echo 'TestCommand2'
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
476 call setline(1, ['', '', '', '', ''])
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
477 call cursor(5, 1)
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
478
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
479 " Without completion menu scrolling can move text.
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
480 set completeopt-=menu wrap
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
481 call feedkeys("ccT\<C-X>\<C-V>\<ScrollWheelDown>\<C-V>", 'tx')
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
482 call assert_equal('TestCommand2', getline('.'))
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
483 call assert_notequal(1, winsaveview().topline)
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
484 call feedkeys("ccT\<C-X>\<C-V>\<ScrollWheelUp>\<C-V>", 'tx')
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
485 call assert_equal('TestCommand2', getline('.'))
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
486 call assert_equal(1, winsaveview().topline)
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
487 set nowrap
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
488 call feedkeys("ccT\<C-X>\<C-V>\<ScrollWheelRight>\<C-V>", 'tx')
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
489 call assert_equal('TestCommand2', getline('.'))
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
490 call assert_notequal(0, winsaveview().leftcol)
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
491 call feedkeys("ccT\<C-X>\<C-V>\<ScrollWheelLeft>\<C-V>", 'tx')
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
492 call assert_equal('TestCommand2', getline('.'))
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
493 call assert_equal(0, winsaveview().leftcol)
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
494 call feedkeys("ccT\<C-X>\<C-V>\<MouseMove>\<C-V>", 'tx')
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
495 call assert_equal('TestCommand2', getline('.'))
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
496
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
497 " With completion menu scrolling cannot move text.
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
498 set completeopt+=menu wrap
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
499 call feedkeys("ccT\<C-X>\<C-V>\<ScrollWheelDown>\<C-V>", 'tx')
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
500 call assert_equal('TestCommand2', getline('.'))
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
501 call assert_equal(1, winsaveview().topline)
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
502 call feedkeys("ccT\<C-X>\<C-V>\<ScrollWheelUp>\<C-V>", 'tx')
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
503 call assert_equal('TestCommand2', getline('.'))
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
504 call assert_equal(1, winsaveview().topline)
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
505 set nowrap
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
506 call feedkeys("ccT\<C-X>\<C-V>\<ScrollWheelRight>\<C-V>", 'tx')
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
507 call assert_equal('TestCommand2', getline('.'))
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
508 call assert_equal(0, winsaveview().leftcol)
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
509 call feedkeys("ccT\<C-X>\<C-V>\<ScrollWheelLeft>\<C-V>", 'tx')
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
510 call assert_equal('TestCommand2', getline('.'))
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
511 call assert_equal(0, winsaveview().leftcol)
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
512 call feedkeys("ccT\<C-X>\<C-V>\<MouseMove>\<C-V>", 'tx')
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
513 call assert_equal('TestCommand2', getline('.'))
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
514
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
515 bwipe!
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
516 set completeopt& wrap&
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
517 endfunc
fc1d95479511 patch 9.0.1371: ballooneval interferes with Insert completion
Bram Moolenaar <Bram@vim.org>
parents: 31849
diff changeset
518
13215
ae5f855a64be patch 8.0.1482: using feedkeys() does not work to test completion
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
519 " 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
520 " completions.
ae5f855a64be patch 8.0.1482: using feedkeys() does not work to test completion
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
521 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
522 new
ae5f855a64be patch 8.0.1482: using feedkeys() does not work to test completion
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
523 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
524 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
525 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
526 bwipe!
ae5f855a64be patch 8.0.1482: using feedkeys() does not work to test completion
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
527 set completeopt&
ae5f855a64be patch 8.0.1482: using feedkeys() does not work to test completion
Christian Brabandt <cb@256bit.org>
parents: 12788
diff changeset
528 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
529
17543
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
530 " 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
531 func Test_ins_completeslash()
17588
1348696d07cd patch 8.1.1791: 'completeslash' also applies to globpath()
Bram Moolenaar <Bram@vim.org>
parents: 17553
diff changeset
532 CheckMSWindows
22397
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22248
diff changeset
533
30580
f08ed0738f7a patch 9.0.0625: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30487
diff changeset
534 call mkdir('Xcpldir', 'R')
17543
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
535 let orig_shellslash = &shellslash
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
536 set cpt&
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
537 new
22397
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22248
diff changeset
538
17543
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
539 set noshellslash
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
540
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
541 set completeslash=
29974
aafac1ae89c7 patch 9.0.0325: MS-Windows: completion test fails
Bram Moolenaar <Bram@vim.org>
parents: 29970
diff changeset
542 exe "normal oXcp\<C-X>\<C-F>"
29970
d891115c0aea patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents: 29554
diff changeset
543 call assert_equal('Xcpldir\', getline('.'))
17543
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
544
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
545 set completeslash=backslash
29974
aafac1ae89c7 patch 9.0.0325: MS-Windows: completion test fails
Bram Moolenaar <Bram@vim.org>
parents: 29970
diff changeset
546 exe "normal oXcp\<C-X>\<C-F>"
29970
d891115c0aea patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents: 29554
diff changeset
547 call assert_equal('Xcpldir\', getline('.'))
17543
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
548
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
549 set completeslash=slash
29974
aafac1ae89c7 patch 9.0.0325: MS-Windows: completion test fails
Bram Moolenaar <Bram@vim.org>
parents: 29970
diff changeset
550 exe "normal oXcp\<C-X>\<C-F>"
29970
d891115c0aea patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents: 29554
diff changeset
551 call assert_equal('Xcpldir/', getline('.'))
17543
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
552
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
553 set shellslash
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
554
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
555 set completeslash=
29974
aafac1ae89c7 patch 9.0.0325: MS-Windows: completion test fails
Bram Moolenaar <Bram@vim.org>
parents: 29970
diff changeset
556 exe "normal oXcp\<C-X>\<C-F>"
29970
d891115c0aea patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents: 29554
diff changeset
557 call assert_equal('Xcpldir/', getline('.'))
17543
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
558
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
559 set completeslash=backslash
29974
aafac1ae89c7 patch 9.0.0325: MS-Windows: completion test fails
Bram Moolenaar <Bram@vim.org>
parents: 29970
diff changeset
560 exe "normal oXcp\<C-X>\<C-F>"
29970
d891115c0aea patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents: 29554
diff changeset
561 call assert_equal('Xcpldir\', getline('.'))
17543
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
562
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
563 set completeslash=slash
29974
aafac1ae89c7 patch 9.0.0325: MS-Windows: completion test fails
Bram Moolenaar <Bram@vim.org>
parents: 29970
diff changeset
564 exe "normal oXcp\<C-X>\<C-F>"
29970
d891115c0aea patch 9.0.0323: using common name in tests leads to flaky tests
Bram Moolenaar <Bram@vim.org>
parents: 29554
diff changeset
565 call assert_equal('Xcpldir/', getline('.'))
17543
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
566 %bw!
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
567
17588
1348696d07cd patch 8.1.1791: 'completeslash' also applies to globpath()
Bram Moolenaar <Bram@vim.org>
parents: 17553
diff changeset
568 set noshellslash
1348696d07cd patch 8.1.1791: 'completeslash' also applies to globpath()
Bram Moolenaar <Bram@vim.org>
parents: 17553
diff changeset
569 set completeslash=slash
1348696d07cd patch 8.1.1791: 'completeslash' also applies to globpath()
Bram Moolenaar <Bram@vim.org>
parents: 17553
diff changeset
570 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
571
17543
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
572 let &shellslash = orig_shellslash
17588
1348696d07cd patch 8.1.1791: 'completeslash' also applies to globpath()
Bram Moolenaar <Bram@vim.org>
parents: 17553
diff changeset
573 set completeslash=
17543
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
574 endfunc
77c3f6428b6c patch 8.1.1769: 'shellslash' is also used for completion
Bram Moolenaar <Bram@vim.org>
parents: 17468
diff changeset
575
22427
58cdc5d7f143 patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
576 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
577 CheckScreendump
58cdc5d7f143 patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
578
58cdc5d7f143 patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
579 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
580 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
581 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
582 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
583 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
584 endfunc
58cdc5d7f143 patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
585 END
58cdc5d7f143 patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
586
30580
f08ed0738f7a patch 9.0.0625: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30487
diff changeset
587 call writefile(lines, 'Xpumscript', 'D')
22427
58cdc5d7f143 patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
588 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
589 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
590 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
591 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
592 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
593
58cdc5d7f143 patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
594 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
595 endfunc
58cdc5d7f143 patch 8.2.1762: when a timer uses :stopinsert completion isn't stopped
Bram Moolenaar <Bram@vim.org>
parents: 22397
diff changeset
596
28682
c1591fa6f81a patch 8.2.4865: :startinsert right after :stopinsert may not work
Bram Moolenaar <Bram@vim.org>
parents: 28369
diff changeset
597 func Test_complete_stopinsert_startinsert()
c1591fa6f81a patch 8.2.4865: :startinsert right after :stopinsert may not work
Bram Moolenaar <Bram@vim.org>
parents: 28369
diff changeset
598 nnoremap <F2> <Cmd>startinsert<CR>
c1591fa6f81a patch 8.2.4865: :startinsert right after :stopinsert may not work
Bram Moolenaar <Bram@vim.org>
parents: 28369
diff changeset
599 inoremap <F2> <Cmd>stopinsert<CR>
c1591fa6f81a patch 8.2.4865: :startinsert right after :stopinsert may not work
Bram Moolenaar <Bram@vim.org>
parents: 28369
diff changeset
600 " This just checks if this causes an error
c1591fa6f81a patch 8.2.4865: :startinsert right after :stopinsert may not work
Bram Moolenaar <Bram@vim.org>
parents: 28369
diff changeset
601 call feedkeys("i\<C-X>\<C-N>\<F2>\<F2>", 'x')
c1591fa6f81a patch 8.2.4865: :startinsert right after :stopinsert may not work
Bram Moolenaar <Bram@vim.org>
parents: 28369
diff changeset
602 nunmap <F2>
c1591fa6f81a patch 8.2.4865: :startinsert right after :stopinsert may not work
Bram Moolenaar <Bram@vim.org>
parents: 28369
diff changeset
603 iunmap <F2>
c1591fa6f81a patch 8.2.4865: :startinsert right after :stopinsert may not work
Bram Moolenaar <Bram@vim.org>
parents: 28369
diff changeset
604 endfunc
c1591fa6f81a patch 8.2.4865: :startinsert right after :stopinsert may not work
Bram Moolenaar <Bram@vim.org>
parents: 28369
diff changeset
605
18892
fb2d26bc8ca1 patch 8.2.0007: popup menu positioned wrong with folding in two tabs
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
606 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
607 CheckScreendump
fb2d26bc8ca1 patch 8.2.0007: popup menu positioned wrong with folding in two tabs
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
608
fb2d26bc8ca1 patch 8.2.0007: popup menu positioned wrong with folding in two tabs
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
609 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
610 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
611 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
612 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
613 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
614 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
615 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
616 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
617 END
fb2d26bc8ca1 patch 8.2.0007: popup menu positioned wrong with folding in two tabs
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
618
30580
f08ed0738f7a patch 9.0.0625: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30487
diff changeset
619 call writefile(lines, 'Xpumscript', 'D')
18892
fb2d26bc8ca1 patch 8.2.0007: popup menu positioned wrong with folding in two tabs
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
620 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
621 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
622 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
623 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
624
fb2d26bc8ca1 patch 8.2.0007: popup menu positioned wrong with folding in two tabs
Bram Moolenaar <Bram@vim.org>
parents: 17588
diff changeset
625 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
626 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
627 endfunc
18900
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
628
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
629 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
630 CheckScreendump
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
631
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
632 let lines =<< trim END
35281
3df74ca6432d patch 9.1.0447: completion may be wrong when deleting all chars
Christian Brabandt <cb@256bit.org>
parents: 34753
diff changeset
633 func Omni_test(findstart, base)
3df74ca6432d patch 9.1.0447: completion may be wrong when deleting all chars
Christian Brabandt <cb@256bit.org>
parents: 34753
diff changeset
634 if a:findstart
3df74ca6432d patch 9.1.0447: completion may be wrong when deleting all chars
Christian Brabandt <cb@256bit.org>
parents: 34753
diff changeset
635 return col(".") - 1
3df74ca6432d patch 9.1.0447: completion may be wrong when deleting all chars
Christian Brabandt <cb@256bit.org>
parents: 34753
diff changeset
636 endif
3df74ca6432d patch 9.1.0447: completion may be wrong when deleting all chars
Christian Brabandt <cb@256bit.org>
parents: 34753
diff changeset
637 return [#{word: "one", info: "1info"}, #{word: "two", info: "2info"}, #{word: "three", info: "3info"}]
3df74ca6432d patch 9.1.0447: completion may be wrong when deleting all chars
Christian Brabandt <cb@256bit.org>
parents: 34753
diff changeset
638 endfunc
3df74ca6432d patch 9.1.0447: completion may be wrong when deleting all chars
Christian Brabandt <cb@256bit.org>
parents: 34753
diff changeset
639 set omnifunc=Omni_test
3df74ca6432d patch 9.1.0447: completion may be wrong when deleting all chars
Christian Brabandt <cb@256bit.org>
parents: 34753
diff changeset
640 set completeopt+=longest
18900
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
641 END
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
642
30580
f08ed0738f7a patch 9.0.0625: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30487
diff changeset
643 call writefile(lines, 'Xpreviewscript', 'D')
18900
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
644 let buf = RunVimInTerminal('-S Xpreviewscript', #{rows: 12})
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
645 call term_sendkeys(buf, "Gi\<C-X>\<C-O>")
30487
79e2d9b7780c patch 9.0.0579: using freed memory when 'tagfunc' wipes out buffer
Bram Moolenaar <Bram@vim.org>
parents: 30473
diff changeset
646 call TermWait(buf, 200)
18900
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
647 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
648 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
649
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
650 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
651 call StopVimInTerminal(buf)
a9c47c623f4a patch 8.2.0011: screen updating wrong when opeing preview window
Bram Moolenaar <Bram@vim.org>
parents: 18892
diff changeset
652 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
653
27944
05fa2837e8a1 patch 8.2.4497: wrong color for half of wide character next to pum scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 27780
diff changeset
654 func Test_scrollbar_on_wide_char()
05fa2837e8a1 patch 8.2.4497: wrong color for half of wide character next to pum scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 27780
diff changeset
655 CheckScreendump
05fa2837e8a1 patch 8.2.4497: wrong color for half of wide character next to pum scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 27780
diff changeset
656
05fa2837e8a1 patch 8.2.4497: wrong color for half of wide character next to pum scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 27780
diff changeset
657 let lines =<< trim END
05fa2837e8a1 patch 8.2.4497: wrong color for half of wide character next to pum scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 27780
diff changeset
658 call setline(1, ['a', ' å•Šå•Šå•Š',
05fa2837e8a1 patch 8.2.4497: wrong color for half of wide character next to pum scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 27780
diff changeset
659 \ ' 哦哦哦',
05fa2837e8a1 patch 8.2.4497: wrong color for half of wide character next to pum scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 27780
diff changeset
660 \ ' 呃呃呃'])
05fa2837e8a1 patch 8.2.4497: wrong color for half of wide character next to pum scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 27780
diff changeset
661 call setline(5, range(10)->map({i, v -> 'aa' .. v .. 'bb'}))
05fa2837e8a1 patch 8.2.4497: wrong color for half of wide character next to pum scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 27780
diff changeset
662 END
30580
f08ed0738f7a patch 9.0.0625: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30487
diff changeset
663 call writefile(lines, 'Xwidescript', 'D')
27944
05fa2837e8a1 patch 8.2.4497: wrong color for half of wide character next to pum scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 27780
diff changeset
664 let buf = RunVimInTerminal('-S Xwidescript', #{rows: 10})
05fa2837e8a1 patch 8.2.4497: wrong color for half of wide character next to pum scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 27780
diff changeset
665 call term_sendkeys(buf, "A\<C-N>")
05fa2837e8a1 patch 8.2.4497: wrong color for half of wide character next to pum scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 27780
diff changeset
666 call VerifyScreenDump(buf, 'Test_scrollbar_on_wide_char', {})
05fa2837e8a1 patch 8.2.4497: wrong color for half of wide character next to pum scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 27780
diff changeset
667
05fa2837e8a1 patch 8.2.4497: wrong color for half of wide character next to pum scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 27780
diff changeset
668 call StopVimInTerminal(buf)
05fa2837e8a1 patch 8.2.4497: wrong color for half of wide character next to pum scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 27780
diff changeset
669 endfunc
05fa2837e8a1 patch 8.2.4497: wrong color for half of wide character next to pum scrollbar
Bram Moolenaar <Bram@vim.org>
parents: 27780
diff changeset
670
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
671 " 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
672 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
673 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
674 \ "!_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
675 \ "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
676 \ "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
677 \ "third\tXfoo\t/^int third() {}$/"],
30580
f08ed0738f7a patch 9.0.0625: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30487
diff changeset
678 \ 'Xtags', 'D')
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
679 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
680 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
681 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
682 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
683 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
684 [CODE]
30580
f08ed0738f7a patch 9.0.0625: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30487
diff changeset
685 call writefile(code, 'Xfoo', 'D')
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
686
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 19047
diff changeset
687 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
688 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
689 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
690 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
691 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
692
8645b73b3645 patch 8.2.0088: insufficient tests for tags; bug in using extra tag field
Bram Moolenaar <Bram@vim.org>
parents: 19047
diff changeset
693 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
694 %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
695 endfunc
19932
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19651
diff changeset
696
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19651
diff changeset
697 " 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
698 func Test_completefunc_error()
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19651
diff changeset
699 new
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
700 " 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
701 func CompleteFunc(findstart, base)
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19651
diff changeset
702 if a:findstart == 1
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19651
diff changeset
703 normal dd
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19651
diff changeset
704 return col('.') - 1
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19651
diff changeset
705 endif
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19651
diff changeset
706 return ['a', 'b']
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19651
diff changeset
707 endfunc
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19651
diff changeset
708 set completefunc=CompleteFunc
2c4d9ca33769 patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents: 19651
diff changeset
709 call setline(1, ['', 'abcd', ''])
29014
45c182c4f7e9 patch 8.2.5029: "textlock" is always zero
Bram Moolenaar <Bram@vim.org>
parents: 29000
diff changeset
710 call assert_fails('exe "normal 2G$a\<C-X>\<C-U>"', 'E565:')
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
711
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
712 " 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
713 func CompleteFunc2(findstart, base)
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
714 if a:findstart == 1
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
715 return col('.') - 1
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
716 endif
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
717 normal dd
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
718 return ['a', 'b']
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
719 endfunc
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
720 set completefunc=CompleteFunc2
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
721 call setline(1, ['', 'abcd', ''])
29014
45c182c4f7e9 patch 8.2.5029: "textlock" is always zero
Bram Moolenaar <Bram@vim.org>
parents: 29000
diff changeset
722 call assert_fails('exe "normal 2G$a\<C-X>\<C-U>"', 'E565:')
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
723
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
724 " 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
725 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
726 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
727 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
728 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
729 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
730 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
731 endfunc
23770
385d33dfb7df patch 8.2.2426: allowing 'completefunc' to switch windows causes trouble
Bram Moolenaar <Bram@vim.org>
parents: 23766
diff changeset
732 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
733 new
23770
385d33dfb7df patch 8.2.2426: allowing 'completefunc' to switch windows causes trouble
Bram Moolenaar <Bram@vim.org>
parents: 23766
diff changeset
734 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
735 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
736
704fdd4d0949 patch 8.2.2424: some tests are known to cause an error with ASAN
Bram Moolenaar <Bram@vim.org>
parents: 23748
diff changeset
737 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
738 delfunc CompleteFunc
23770
385d33dfb7df patch 8.2.2426: allowing 'completefunc' to switch windows causes trouble
Bram Moolenaar <Bram@vim.org>
parents: 23766
diff changeset
739 delfunc CompleteFunc2
385d33dfb7df patch 8.2.2426: allowing 'completefunc' to switch windows causes trouble
Bram Moolenaar <Bram@vim.org>
parents: 23766
diff changeset
740 delfunc CompleteFunc3
385d33dfb7df patch 8.2.2426: allowing 'completefunc' to switch windows causes trouble
Bram Moolenaar <Bram@vim.org>
parents: 23766
diff changeset
741 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
742 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
743
20285
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
744 " 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
745 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
746 new
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
747 func! CompleteFunc(findstart, base)
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
748 if a:findstart == 1
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
749 return col('.') - 1
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
750 endif
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
751 return [{}, '', 'moon']
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
752 endfunc
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
753 set completefunc=CompleteFunc
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
754 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
755 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
756 set completefunc&
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
757 close!
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
758 endfunc
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
759
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
760 " 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
761 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
762 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
763 func ListColors()
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
764 call complete(col('.'), "blue")
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
765 endfunc
30015
adb0de8be4ce patch 9.0.0345: error message for list argument could be clearer
Bram Moolenaar <Bram@vim.org>
parents: 29974
diff changeset
766 call assert_fails('exe "normal i\<C-R>=ListColors()\<CR>"', 'E1211:')
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
767 func ListMonths()
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
768 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
769 endfunc
30015
adb0de8be4ce patch 9.0.0345: error message for list argument could be clearer
Bram Moolenaar <Bram@vim.org>
parents: 29974
diff changeset
770 call assert_fails('exe "normal i\<C-R>=ListMonths()\<CR>"', 'E1298:')
20120
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
771 delfunc ListColors
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
772 delfunc ListMonths
30015
adb0de8be4ce patch 9.0.0345: error message for list argument could be clearer
Bram Moolenaar <Bram@vim.org>
parents: 29974
diff changeset
773 call assert_fails('call complete_info({})', 'E1211:')
20285
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
774 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
775 endfunc
16460964c304 patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
776
26921
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
777 " Test for recursively starting completion mode using complete()
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
778 func Test_recursive_complete_func()
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
779 func ListColors()
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
780 call complete(5, ["red", "blue"])
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
781 return ''
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
782 endfunc
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
783 new
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
784 call setline(1, ['a1', 'a2'])
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
785 set complete=.
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
786 exe "normal Goa\<C-X>\<C-L>\<C-R>=ListColors()\<CR>\<C-N>"
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
787 call assert_equal('a2blue', getline(3))
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
788 delfunc ListColors
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
789 bw!
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
790 endfunc
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
791
30463
faecc8c6916f patch 9.0.0567: 'completeopt' "longest" is not used for complete()
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
792 " Test for using complete() with completeopt+=longest
faecc8c6916f patch 9.0.0567: 'completeopt' "longest" is not used for complete()
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
793 func Test_complete_with_longest()
faecc8c6916f patch 9.0.0567: 'completeopt' "longest" is not used for complete()
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
794 new
30473
1928947b8e1a patch 9.0.0572: insert complete tests leave a mapping behind
Bram Moolenaar <Bram@vim.org>
parents: 30463
diff changeset
795 inoremap <buffer> <f3> <cmd>call complete(1, ["iaax", "iaay", "iaaz"])<cr>
30463
faecc8c6916f patch 9.0.0567: 'completeopt' "longest" is not used for complete()
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
796
faecc8c6916f patch 9.0.0567: 'completeopt' "longest" is not used for complete()
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
797 " default: insert first match
faecc8c6916f patch 9.0.0567: 'completeopt' "longest" is not used for complete()
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
798 set completeopt&
faecc8c6916f patch 9.0.0567: 'completeopt' "longest" is not used for complete()
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
799 call setline(1, ['i'])
faecc8c6916f patch 9.0.0567: 'completeopt' "longest" is not used for complete()
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
800 exe "normal Aa\<f3>\<esc>"
faecc8c6916f patch 9.0.0567: 'completeopt' "longest" is not used for complete()
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
801 call assert_equal('iaax', getline(1))
faecc8c6916f patch 9.0.0567: 'completeopt' "longest" is not used for complete()
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
802
faecc8c6916f patch 9.0.0567: 'completeopt' "longest" is not used for complete()
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
803 " with longest: insert longest prefix
faecc8c6916f patch 9.0.0567: 'completeopt' "longest" is not used for complete()
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
804 set completeopt+=longest
faecc8c6916f patch 9.0.0567: 'completeopt' "longest" is not used for complete()
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
805 call setline(1, ['i'])
faecc8c6916f patch 9.0.0567: 'completeopt' "longest" is not used for complete()
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
806 exe "normal Aa\<f3>\<esc>"
faecc8c6916f patch 9.0.0567: 'completeopt' "longest" is not used for complete()
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
807 call assert_equal('iaa', getline(1))
faecc8c6916f patch 9.0.0567: 'completeopt' "longest" is not used for complete()
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
808 set completeopt&
30473
1928947b8e1a patch 9.0.0572: insert complete tests leave a mapping behind
Bram Moolenaar <Bram@vim.org>
parents: 30463
diff changeset
809 bwipe!
30463
faecc8c6916f patch 9.0.0567: 'completeopt' "longest" is not used for complete()
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
810 endfunc
faecc8c6916f patch 9.0.0567: 'completeopt' "longest" is not used for complete()
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
811
35340
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
812 " Test for buffer-local value of 'completeopt'
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
813 func Test_completeopt_buffer_local()
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
814 set completeopt=menu
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
815 new
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
816 call setline(1, ['foofoo', 'foobar', 'foobaz', ''])
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
817 call assert_equal('', &l:completeopt)
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
818 call assert_equal('menu', &completeopt)
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
819 call assert_equal('menu', &g:completeopt)
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
820
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
821 setlocal bufhidden=hide
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
822 enew
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
823 call setline(1, ['foofoo', 'foobar', 'foobaz', ''])
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
824 call assert_equal('', &l:completeopt)
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
825 call assert_equal('menu', &completeopt)
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
826 call assert_equal('menu', &g:completeopt)
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
827
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
828 setlocal completeopt+=fuzzy,noinsert
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
829 call assert_equal('menu,fuzzy,noinsert', &l:completeopt)
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
830 call assert_equal('menu,fuzzy,noinsert', &completeopt)
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
831 call assert_equal('menu', &g:completeopt)
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
832 call feedkeys("Gccf\<C-X>\<C-N>bz\<C-Y>", 'tnix')
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
833 call assert_equal('foobaz', getline('.'))
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
834
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
835 setlocal completeopt=
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
836 call assert_equal('', &l:completeopt)
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
837 call assert_equal('menu', &completeopt)
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
838 call assert_equal('menu', &g:completeopt)
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
839 call feedkeys("Gccf\<C-X>\<C-N>\<C-Y>", 'tnix')
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
840 call assert_equal('foofoo', getline('.'))
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
841
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
842 setlocal completeopt+=longest
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
843 call assert_equal('menu,longest', &l:completeopt)
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
844 call assert_equal('menu,longest', &completeopt)
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
845 call assert_equal('menu', &g:completeopt)
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
846 call feedkeys("Gccf\<C-X>\<C-N>\<C-X>\<C-Z>", 'tnix')
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
847 call assert_equal('foo', getline('.'))
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
848
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
849 setlocal bufhidden=hide
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
850 buffer #
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
851 call assert_equal('', &l:completeopt)
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
852 call assert_equal('menu', &completeopt)
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
853 call assert_equal('menu', &g:completeopt)
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
854 call feedkeys("Gccf\<C-X>\<C-N>\<C-Y>", 'tnix')
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
855 call assert_equal('foofoo', getline('.'))
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
856
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
857 setlocal completeopt+=fuzzy,noinsert
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
858 call assert_equal('menu,fuzzy,noinsert', &l:completeopt)
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
859 call assert_equal('menu,fuzzy,noinsert', &completeopt)
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
860 call assert_equal('menu', &g:completeopt)
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
861 call feedkeys("Gccf\<C-X>\<C-N>bz\<C-Y>", 'tnix')
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
862 call assert_equal('foobaz', getline('.'))
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
863
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
864 buffer #
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
865 call assert_equal('menu,longest', &l:completeopt)
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
866 call assert_equal('menu,longest', &completeopt)
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
867 call assert_equal('menu', &g:completeopt)
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
868 call feedkeys("Gccf\<C-X>\<C-N>\<C-X>\<C-Z>", 'tnix')
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
869 call assert_equal('foo', getline('.'))
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
870
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
871 setlocal bufhidden=wipe
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
872 buffer! #
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
873 bwipe!
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
874 call assert_equal('', &l:completeopt)
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
875 call assert_equal('menu', &completeopt)
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
876 call assert_equal('menu', &g:completeopt)
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
877
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
878 set completeopt&
5c4e1b16db10 patch 9.1.0469: Cannot have buffer-local value for 'completeopt'
Christian Brabandt <cb@256bit.org>
parents: 35335
diff changeset
879 endfunc
30463
faecc8c6916f patch 9.0.0567: 'completeopt' "longest" is not used for complete()
Bram Moolenaar <Bram@vim.org>
parents: 30051
diff changeset
880
20199
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
881 " 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
882 func Test_complete_wrapscan()
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
883 " complete words from another buffer
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
884 new
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
885 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
886 new
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
887 setlocal complete=w
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
888 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
889 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
890 close!
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
891 " 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
892 setlocal complete=.
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
893 %d
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
894 call setline(1, ['one two', ''])
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
895 call cursor(2, 1)
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
896 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
897 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
898 close!
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
899 endfunc
a4bd28e2cf1d patch 8.2.0655: search code not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 20120
diff changeset
900
20285
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
901 " 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
902 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
903 new
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
904 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
905 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
906 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
907 close!
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
908 endfunc
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
909
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
910 " 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
911 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
912 new
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
913 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
914 setlocal textwidth=20
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
915 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
916 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
917 close!
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
918 endfunc
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
919
26817
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
920 " Test for completing words with a '.' at the end of a word.
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
921 func Test_complete_joinspaces()
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
922 new
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
923 call setline(1, ['one two.', 'three. four'])
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
924 set joinspaces
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
925 exe "normal Goon\<C-P>\<C-X>\<C-P>\<C-X>\<C-P>\<C-X>\<C-P>\<C-X>\<C-P>"
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
926 call assert_equal("one two. three. four", getline(3))
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
927 set joinspaces&
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
928 bw!
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
929 endfunc
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
930
20285
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
931 " 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
932 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
933 new
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
934 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
935 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
936 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
937
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
938 " 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
939 " 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
940 %d
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
941 set ignorecase backspace=2
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
942 setlocal complete=.
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
943 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
944 normal Go
33589
efe4751b93b1 patch 9.0.2039: completion shows current word after completion restart
Christian Brabandt <cb@256bit.org>
parents: 33538
diff changeset
945 exe "normal aWOR\<C-P>\<bs>\<bs>\<bs>\<bs>\<bs>\<bs>\<C-L>\<C-L>\<C-L>"
20285
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
946 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
947 set ignorecase& backspace&
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
948 close!
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
949 endfunc
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
950
26817
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
951 " Test for using CTRL-X CTRL-L to complete whole lines lines
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
952 func Test_complete_wholeline()
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
953 new
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
954 " complete one-line
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
955 call setline(1, ['a1', 'a2'])
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
956 exe "normal ggoa\<C-X>\<C-L>"
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
957 call assert_equal(['a1', 'a1', 'a2'], getline(1, '$'))
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
958 " go to the next match (wrapping around the buffer)
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
959 exe "normal 2GCa\<C-X>\<C-L>\<C-N>"
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
960 call assert_equal(['a1', 'a', 'a2'], getline(1, '$'))
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
961 " go to the next match
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
962 exe "normal 2GCa\<C-X>\<C-L>\<C-N>\<C-N>"
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
963 call assert_equal(['a1', 'a2', 'a2'], getline(1, '$'))
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
964 exe "normal 2GCa\<C-X>\<C-L>\<C-N>\<C-N>\<C-N>"
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
965 call assert_equal(['a1', 'a1', 'a2'], getline(1, '$'))
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
966 " repeat the test using CTRL-L
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
967 " go to the next match (wrapping around the buffer)
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
968 exe "normal 2GCa\<C-X>\<C-L>\<C-L>"
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
969 call assert_equal(['a1', 'a2', 'a2'], getline(1, '$'))
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
970 " go to the next match
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
971 exe "normal 2GCa\<C-X>\<C-L>\<C-L>\<C-L>"
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
972 call assert_equal(['a1', 'a', 'a2'], getline(1, '$'))
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
973 exe "normal 2GCa\<C-X>\<C-L>\<C-L>\<C-L>\<C-L>"
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
974 call assert_equal(['a1', 'a1', 'a2'], getline(1, '$'))
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
975 %d
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
976 " use CTRL-X CTRL-L to add one more line
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
977 call setline(1, ['a1', 'b1'])
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
978 setlocal complete=.
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
979 exe "normal ggOa\<C-X>\<C-L>\<C-X>\<C-L>\<C-X>\<C-L>"
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
980 call assert_equal(['a1', 'b1', '', 'a1', 'b1'], getline(1, '$'))
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
981 bw!
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
982 endfunc
a8ded20a59e6 patch 8.2.3937: Insert mode completion function is too long
Bram Moolenaar <Bram@vim.org>
parents: 26773
diff changeset
983
20285
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
984 " 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
985 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
986 new
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
987 setlocal cindent
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
988 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
989 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
990 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
991
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
992 %d
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
993 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
994 setlocal cinkeys+==while
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
995 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
996 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
997 close!
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
998 endfunc
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
999
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
1000 " 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
1001 func Test_complete_cmdline()
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
1002 new
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
1003 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
1004 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
1005 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
1006 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
1007 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
1008 call assert_equal('abcxyz(', getline(3))
25707
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1009 com! -buffer TestCommand1 echo 'TestCommand1'
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1010 com! -buffer TestCommand2 echo 'TestCommand2'
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1011 write TestCommand1Test
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1012 write TestCommand2Test
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1013 " Test repeating <CTRL-X> <CTRL-V> and switching to another CTRL-X mode
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1014 exe "normal oT\<C-X>\<C-V>\<C-X>\<C-V>\<C-X>\<C-F>\<Esc>"
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1015 call assert_equal('TestCommand2Test', getline(4))
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1016 call delete('TestCommand1Test')
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1017 call delete('TestCommand2Test')
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1018 delcom TestCommand1
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1019 delcom TestCommand2
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1020 close!
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1021 endfunc
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1022
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1023 " Test for <CTRL-X> <CTRL-Z> stopping completion without changing the match
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1024 func Test_complete_stop()
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1025 new
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1026 func Save_mode1()
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1027 let g:mode1 = mode(1)
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1028 return ''
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1029 endfunc
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1030 func Save_mode2()
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1031 let g:mode2 = mode(1)
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1032 return ''
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1033 endfunc
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1034 inoremap <F1> <C-R>=Save_mode1()<CR>
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1035 inoremap <F2> <C-R>=Save_mode2()<CR>
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1036 call setline(1, ['aaa bbb ccc '])
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1037 exe "normal A\<C-N>\<C-P>\<F1>\<C-X>\<C-Z>\<F2>\<Esc>"
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1038 call assert_equal('ic', g:mode1)
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1039 call assert_equal('i', g:mode2)
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1040 call assert_equal('aaa bbb ccc ', getline(1))
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1041 exe "normal A\<C-N>\<Down>\<F1>\<C-X>\<C-Z>\<F2>\<Esc>"
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1042 call assert_equal('ic', g:mode1)
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1043 call assert_equal('i', g:mode2)
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1044 call assert_equal('aaa bbb ccc aaa', getline(1))
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1045 set completeopt+=noselect
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1046 exe "normal A \<C-N>\<Down>\<Down>\<C-L>\<C-L>\<F1>\<C-X>\<C-Z>\<F2>\<Esc>"
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1047 call assert_equal('ic', g:mode1)
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1048 call assert_equal('i', g:mode2)
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1049 call assert_equal('aaa bbb ccc aaa bb', getline(1))
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1050 set completeopt&
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1051 exe "normal A d\<C-N>\<F1>\<C-X>\<C-Z>\<F2>\<Esc>"
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1052 call assert_equal('ic', g:mode1)
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1053 call assert_equal('i', g:mode2)
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1054 call assert_equal('aaa bbb ccc aaa bb d', getline(1))
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1055 com! -buffer TestCommand1 echo 'TestCommand1'
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1056 com! -buffer TestCommand2 echo 'TestCommand2'
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1057 exe "normal oT\<C-X>\<C-V>\<C-X>\<C-V>\<F1>\<C-X>\<C-Z>\<F2>\<Esc>"
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1058 call assert_equal('ic', g:mode1)
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1059 call assert_equal('i', g:mode2)
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1060 call assert_equal('TestCommand2', getline(2))
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1061 delcom TestCommand1
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1062 delcom TestCommand2
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1063 unlet g:mode1
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1064 unlet g:mode2
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1065 iunmap <F1>
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1066 iunmap <F2>
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1067 delfunc Save_mode1
31db9c6df4e3 patch 8.2.3389: cannot stop insert mode completion without side effects
Bram Moolenaar <Bram@vim.org>
parents: 25372
diff changeset
1068 delfunc Save_mode2
20285
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
1069 close!
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
1070 endfunc
bce10d039e06 patch 8.2.0698: insert mode completion not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 20229
diff changeset
1071
26831
537fdb6653a9 patch 8.2.3944: insert mode completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents: 26817
diff changeset
1072 " Test for typing CTRL-R in insert completion mode to insert a register
537fdb6653a9 patch 8.2.3944: insert mode completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents: 26817
diff changeset
1073 " content.
537fdb6653a9 patch 8.2.3944: insert mode completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents: 26817
diff changeset
1074 func Test_complete_reginsert()
537fdb6653a9 patch 8.2.3944: insert mode completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents: 26817
diff changeset
1075 new
537fdb6653a9 patch 8.2.3944: insert mode completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents: 26817
diff changeset
1076 call setline(1, ['a1', 'a12', 'a123', 'a1234'])
537fdb6653a9 patch 8.2.3944: insert mode completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents: 26817
diff changeset
1077
537fdb6653a9 patch 8.2.3944: insert mode completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents: 26817
diff changeset
1078 " if a valid CTRL-X mode key is returned from <C-R>=, then it should be
537fdb6653a9 patch 8.2.3944: insert mode completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents: 26817
diff changeset
1079 " processed. Otherwise, CTRL-X mode should be stopped and the key should be
537fdb6653a9 patch 8.2.3944: insert mode completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents: 26817
diff changeset
1080 " inserted.
537fdb6653a9 patch 8.2.3944: insert mode completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents: 26817
diff changeset
1081 exe "normal Goa\<C-P>\<C-R>=\"\\<C-P>\"\<CR>"
537fdb6653a9 patch 8.2.3944: insert mode completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents: 26817
diff changeset
1082 call assert_equal('a123', getline(5))
537fdb6653a9 patch 8.2.3944: insert mode completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents: 26817
diff changeset
1083 let @r = "\<C-P>\<C-P>"
537fdb6653a9 patch 8.2.3944: insert mode completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents: 26817
diff changeset
1084 exe "normal GCa\<C-P>\<C-R>r"
537fdb6653a9 patch 8.2.3944: insert mode completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents: 26817
diff changeset
1085 call assert_equal('a12', getline(5))
537fdb6653a9 patch 8.2.3944: insert mode completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents: 26817
diff changeset
1086 exe "normal GCa\<C-P>\<C-R>=\"x\"\<CR>"
537fdb6653a9 patch 8.2.3944: insert mode completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents: 26817
diff changeset
1087 call assert_equal('a1234x', getline(5))
537fdb6653a9 patch 8.2.3944: insert mode completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents: 26817
diff changeset
1088 bw!
537fdb6653a9 patch 8.2.3944: insert mode completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents: 26817
diff changeset
1089 endfunc
537fdb6653a9 patch 8.2.3944: insert mode completion functions are too long
Bram Moolenaar <Bram@vim.org>
parents: 26817
diff changeset
1090
22397
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22248
diff changeset
1091 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
1092 CheckMSWindows
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22248
diff changeset
1093
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22248
diff changeset
1094 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
1095 set noshellslash
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22248
diff changeset
1096
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22248
diff changeset
1097 set completeslash=slash
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22248
diff changeset
1098 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
1099
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22248
diff changeset
1100 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
1101 set completeslash=
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22248
diff changeset
1102 endfunc
0a5770061295 patch 8.2.1747: result of expand() unexpectedly depends on 'completeslash'
Bram Moolenaar <Bram@vim.org>
parents: 22248
diff changeset
1103
26921
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1104 " Test for 'longest' setting in 'completeopt' with latin1 and utf-8 encodings
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1105 func Test_complete_longest_match()
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1106 for e in ['latin1', 'utf-8']
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1107 exe 'set encoding=' .. e
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1108 new
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1109 set complete=.
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1110 set completeopt=menu,longest
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1111 call setline(1, ['pfx_a1', 'pfx_a12', 'pfx_a123', 'pfx_b1'])
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1112 exe "normal Gopfx\<C-P>"
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1113 call assert_equal('pfx_', getline(5))
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1114 bw!
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1115 endfor
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1116
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1117 " Test for completing additional words with longest match set
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1118 new
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1119 call setline(1, ['abc1', 'abd2'])
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1120 exe "normal Goab\<C-P>\<C-X>\<C-P>"
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1121 call assert_equal('ab', getline(3))
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1122 bw!
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1123 set complete& completeopt&
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1124 endfunc
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1125
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1126 " Test for removing the first displayed completion match and selecting the
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1127 " match just before that.
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1128 func Test_complete_erase_firstmatch()
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1129 new
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1130 call setline(1, ['a12', 'a34', 'a56'])
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1131 set complete=.
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1132 exe "normal Goa\<C-P>\<BS>\<BS>3\<CR>"
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1133 call assert_equal('a34', getline('$'))
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1134 set complete&
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1135 bw!
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1136 endfunc
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1137
27016
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1138 " Test for completing words from unloaded buffers
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1139 func Test_complete_from_unloadedbuf()
30580
f08ed0738f7a patch 9.0.0625: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30487
diff changeset
1140 call writefile(['abc'], "Xfile1", 'D')
f08ed0738f7a patch 9.0.0625: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30487
diff changeset
1141 call writefile(['def'], "Xfile2", 'D')
27016
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1142 edit Xfile1
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1143 edit Xfile2
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1144 new | close
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1145 enew
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1146 bunload Xfile1 Xfile2
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1147 set complete=u
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1148 " complete from an unloaded buffer
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1149 exe "normal! ia\<C-P>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1150 call assert_equal('abc', getline(1))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1151 exe "normal! od\<C-P>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1152 call assert_equal('def', getline(2))
30580
f08ed0738f7a patch 9.0.0625: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30487
diff changeset
1153
27016
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1154 set complete&
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1155 %bw!
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1156 endfunc
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1157
26921
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1158 " Test for completing whole lines from unloaded buffers
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1159 func Test_complete_wholeline_unloadedbuf()
30580
f08ed0738f7a patch 9.0.0625: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30487
diff changeset
1160 call writefile(['a line1', 'a line2', 'a line3'], "Xfile1", 'D')
26921
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1161 edit Xfile1
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1162 enew
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1163 set complete=u
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1164 exe "normal! ia\<C-X>\<C-L>\<C-P>"
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1165 call assert_equal('a line2', getline(1))
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1166 %d
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1167 " completing from an unlisted buffer should fail
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1168 bdel Xfile1
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1169 exe "normal! ia\<C-X>\<C-L>\<C-P>"
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1170 call assert_equal('a', getline(1))
30580
f08ed0738f7a patch 9.0.0625: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30487
diff changeset
1171
26921
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1172 set complete&
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1173 %bw!
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1174 endfunc
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1175
27016
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1176 " Test for completing words from unlisted buffers
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1177 func Test_complete_from_unlistedbuf()
30580
f08ed0738f7a patch 9.0.0625: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30487
diff changeset
1178 call writefile(['abc'], "Xfile1", 'D')
f08ed0738f7a patch 9.0.0625: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30487
diff changeset
1179 call writefile(['def'], "Xfile2", 'D')
27016
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1180 edit Xfile1
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1181 edit Xfile2
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1182 new | close
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1183 bdel Xfile1 Xfile2
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1184 set complete=U
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1185 " complete from an unlisted buffer
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1186 exe "normal! ia\<C-P>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1187 call assert_equal('abc', getline(1))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1188 exe "normal! od\<C-P>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1189 call assert_equal('def', getline(2))
30580
f08ed0738f7a patch 9.0.0625: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30487
diff changeset
1190
27016
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1191 set complete&
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1192 %bw!
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1193 endfunc
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1194
26921
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1195 " Test for completing whole lines from unlisted buffers
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1196 func Test_complete_wholeline_unlistedbuf()
30580
f08ed0738f7a patch 9.0.0625: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30487
diff changeset
1197 call writefile(['a line1', 'a line2', 'a line3'], "Xfile1", 'D')
26921
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1198 edit Xfile1
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1199 enew
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1200 set complete=U
34678
75f7b311ee25 patch 9.1.0220: Few typos in source and test files
Christian Brabandt <cb@256bit.org>
parents: 34596
diff changeset
1201 " completing from an unloaded buffer should fail
26921
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1202 exe "normal! ia\<C-X>\<C-L>\<C-P>"
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1203 call assert_equal('a', getline(1))
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1204 %d
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1205 bdel Xfile1
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1206 exe "normal! ia\<C-X>\<C-L>\<C-P>"
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1207 call assert_equal('a line2', getline(1))
30580
f08ed0738f7a patch 9.0.0625: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30487
diff changeset
1208
26921
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1209 set complete&
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1210 %bw!
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1211 endfunc
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1212
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1213 " Test for adding a multibyte character using CTRL-L in completion mode
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1214 func Test_complete_mbyte_char_add()
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1215 new
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1216 set complete=.
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1217 call setline(1, 'abÄ—')
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1218 exe "normal! oa\<C-P>\<BS>\<BS>\<C-L>\<C-L>"
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1219 call assert_equal('abÄ—', getline(2))
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1220 " Test for a leader with multibyte character
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1221 %d
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1222 call setline(1, 'abÄ—Ä•')
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1223 exe "normal! oabÄ—\<C-P>"
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1224 call assert_equal('abÄ—Ä•', getline(2))
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1225 bw!
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1226 endfunc
b975b7c16ba1 patch 8.2.3989: some insert completion code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 26831
diff changeset
1227
27016
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1228 " Test for using <C-X><C-P> for local expansion even if 'complete' is set to
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1229 " not to complete matches from the local buffer. Also test using multiple
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1230 " <C-X> to cancel the current completion mode.
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1231 func Test_complete_local_expansion()
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1232 new
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1233 set complete=t
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1234 call setline(1, ['abc', 'def'])
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1235 exe "normal! Go\<C-X>\<C-P>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1236 call assert_equal("def", getline(3))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1237 exe "normal! Go\<C-P>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1238 call assert_equal("", getline(4))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1239 exe "normal! Go\<C-X>\<C-N>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1240 call assert_equal("abc", getline(5))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1241 exe "normal! Go\<C-N>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1242 call assert_equal("", getline(6))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1243
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1244 " use multiple <C-X> to cancel the previous completion mode
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1245 exe "normal! Go\<C-P>\<C-X>\<C-P>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1246 call assert_equal("", getline(7))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1247 exe "normal! Go\<C-P>\<C-X>\<C-X>\<C-P>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1248 call assert_equal("", getline(8))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1249 exe "normal! Go\<C-P>\<C-X>\<C-X>\<C-X>\<C-P>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1250 call assert_equal("abc", getline(9))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1251
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1252 " interrupt the current completion mode
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1253 set completeopt=menu,noinsert
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1254 exe "normal! Go\<C-X>\<C-F>\<C-X>\<C-X>\<C-P>\<C-Y>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1255 call assert_equal("abc", getline(10))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1256
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1257 " when only one <C-X> is used to interrupt, do normal expansion
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1258 exe "normal! Go\<C-X>\<C-F>\<C-X>\<C-P>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1259 call assert_equal("", getline(11))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1260 set completeopt&
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1261
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1262 " using two <C-X> in non-completion mode and restarting the same mode
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1263 exe "normal! God\<C-X>\<C-X>\<C-P>\<C-X>\<C-X>\<C-P>\<C-Y>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1264 call assert_equal("def", getline(12))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1265
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1266 " test for adding a match from the original empty text
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1267 %d
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1268 call setline(1, 'abc def g')
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1269 exe "normal! o\<C-X>\<C-P>\<C-N>\<C-X>\<C-P>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1270 call assert_equal('def', getline(2))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1271 exe "normal! 0C\<C-X>\<C-N>\<C-P>\<C-X>\<C-N>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1272 call assert_equal('abc', getline(2))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1273
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1274 bw!
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1275 endfunc
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1276
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1277 " Test for undoing changes after a insert-mode completion
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1278 func Test_complete_undo()
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1279 new
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1280 set complete=.
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1281 " undo with 'ignorecase'
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1282 call setline(1, ['ABOVE', 'BELOW'])
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1283 set ignorecase
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1284 exe "normal! Goab\<C-G>u\<C-P>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1285 call assert_equal("ABOVE", getline(3))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1286 undo
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1287 call assert_equal("ab", getline(3))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1288 set ignorecase&
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1289 %d
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1290 " undo with longest match
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1291 set completeopt=menu,longest
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1292 call setline(1, ['above', 'about'])
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1293 exe "normal! Goa\<C-G>u\<C-P>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1294 call assert_equal("abo", getline(3))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1295 undo
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1296 call assert_equal("a", getline(3))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1297 set completeopt&
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1298 %d
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1299 " undo for line completion
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1300 call setline(1, ['above that change', 'below that change'])
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1301 exe "normal! Goabove\<C-G>u\<C-X>\<C-L>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1302 call assert_equal("above that change", getline(3))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1303 undo
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1304 call assert_equal("above", getline(3))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1305
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1306 bw!
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1307 endfunc
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1308
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1309 " Test for completing a very long word
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1310 func Test_complete_long_word()
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1311 set complete&
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1312 new
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1313 call setline(1, repeat('x', 950) .. ' one two three')
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1314 exe "normal! Gox\<C-X>\<C-P>\<C-X>\<C-P>\<C-X>\<C-P>\<C-X>\<C-P>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1315 call assert_equal(repeat('x', 950) .. ' one two three', getline(2))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1316 %d
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1317 " should fail when more than 950 characters are in a word
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1318 call setline(1, repeat('x', 951) .. ' one two three')
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1319 exe "normal! Gox\<C-X>\<C-P>\<C-X>\<C-P>\<C-X>\<C-P>\<C-X>\<C-P>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1320 call assert_equal(repeat('x', 951), getline(2))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1321
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1322 " Test for adding a very long word to an existing completion
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1323 %d
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1324 call setline(1, ['abc', repeat('x', 1016) .. '012345'])
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1325 exe "normal! Goab\<C-P>\<C-X>\<C-P>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1326 call assert_equal('abc ' .. repeat('x', 1016) .. '0123', getline(3))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1327 bw!
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1328 endfunc
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1329
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1330 " Test for some fields in the complete items used by complete()
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1331 func Test_complete_items()
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1332 func CompleteItems(idx)
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1333 let items = [[#{word: "one", dup: 1, user_data: 'u1'}, #{word: "one", dup: 1, user_data: 'u2'}],
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1334 \ [#{word: "one", dup: 0, user_data: 'u3'}, #{word: "one", dup: 0, user_data: 'u4'}],
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1335 \ [#{word: "one", icase: 1, user_data: 'u7'}, #{word: "oNE", icase: 1, user_data: 'u8'}],
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1336 \ [#{user_data: 'u9'}],
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1337 \ [#{word: "", user_data: 'u10'}],
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1338 \ [#{word: "", empty: 1, user_data: 'u11'}]]
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1339 call complete(col('.'), items[a:idx])
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1340 return ''
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1341 endfunc
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1342 new
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1343 exe "normal! i\<C-R>=CompleteItems(0)\<CR>\<C-N>\<C-Y>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1344 call assert_equal('u2', v:completed_item.user_data)
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1345 call assert_equal('one', getline(1))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1346 exe "normal! o\<C-R>=CompleteItems(1)\<CR>\<C-Y>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1347 call assert_equal('u3', v:completed_item.user_data)
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1348 call assert_equal('one', getline(2))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1349 exe "normal! o\<C-R>=CompleteItems(1)\<CR>\<C-N>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1350 call assert_equal('', getline(3))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1351 set completeopt=menu,noinsert
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1352 exe "normal! o\<C-R>=CompleteItems(2)\<CR>one\<C-N>\<C-Y>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1353 call assert_equal('oNE', getline(4))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1354 call assert_equal('u8', v:completed_item.user_data)
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1355 set completeopt&
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1356 exe "normal! o\<C-R>=CompleteItems(3)\<CR>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1357 call assert_equal('', getline(5))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1358 exe "normal! o\<C-R>=CompleteItems(4)\<CR>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1359 call assert_equal('', getline(6))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1360 exe "normal! o\<C-R>=CompleteItems(5)\<CR>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1361 call assert_equal('', getline(7))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1362 call assert_equal('u11', v:completed_item.user_data)
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1363 " pass invalid argument to complete()
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1364 let cmd = "normal! o\<C-R>=complete(1, [[]])\<CR>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1365 call assert_fails('exe cmd', 'E730:')
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1366 bw!
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1367 delfunc CompleteItems
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1368 endfunc
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1369
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1370 " Test for the "refresh" item in the dict returned by an insert completion
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1371 " function
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1372 func Test_complete_item_refresh_always()
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1373 let g:CallCount = 0
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1374 func! Tcomplete(findstart, base)
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1375 if a:findstart
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1376 " locate the start of the word
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1377 let line = getline('.')
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1378 let start = col('.') - 1
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1379 while start > 0 && line[start - 1] =~ '\a'
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1380 let start -= 1
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1381 endwhile
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1382 return start
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1383 else
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1384 let g:CallCount += 1
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1385 let res = ["update1", "update12", "update123"]
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1386 return #{words: res, refresh: 'always'}
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1387 endif
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1388 endfunc
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1389 new
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1390 set completeopt=menu,longest
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1391 set completefunc=Tcomplete
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1392 exe "normal! iup\<C-X>\<C-U>\<BS>\<BS>\<BS>\<BS>\<BS>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1393 call assert_equal('up', getline(1))
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1394 call assert_equal(2, g:CallCount)
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1395 set completeopt&
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1396 set completefunc&
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1397 bw!
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1398 delfunc Tcomplete
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1399 endfunc
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1400
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1401 " Test for completing from a thesaurus file without read permission
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1402 func Test_complete_unreadable_thesaurus_file()
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1403 CheckUnix
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1404 CheckNotRoot
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1405
30580
f08ed0738f7a patch 9.0.0625: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30487
diff changeset
1406 call writefile(['about', 'above'], 'Xunrfile', 'D')
30051
13b02c1ea0f7 patch 9.0.0363: common names in test files causes tests to be flaky
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
1407 call setfperm('Xunrfile', '---r--r--')
27016
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1408 new
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1409 set complete=sXfile
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1410 exe "normal! ia\<C-P>"
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1411 call assert_equal('a', getline(1))
30580
f08ed0738f7a patch 9.0.0625: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30487
diff changeset
1412
27016
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1413 bw!
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1414 set complete&
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1415 endfunc
1d9a7aa42744 patch 8.2.4037: Insert mode completion is insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26921
diff changeset
1416
23169
5e6855ebc4ea patch 8.2.2130: Insert mode completion messages end up in message history
Bram Moolenaar <Bram@vim.org>
parents: 22717
diff changeset
1417 " 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
1418 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
1419 new
5e6855ebc4ea patch 8.2.2130: Insert mode completion messages end up in message history
Bram Moolenaar <Bram@vim.org>
parents: 22717
diff changeset
1420 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
1421 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
1422 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
1423 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
1424 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
1425 call assert_equal(currmess, execute('messages'))
27954
3de9be15de51 patch 8.2.4502: in the GUI a modifier is not recognized after CTRL-X
Bram Moolenaar <Bram@vim.org>
parents: 27944
diff changeset
1426 bwipe!
3de9be15de51 patch 8.2.4502: in the GUI a modifier is not recognized after CTRL-X
Bram Moolenaar <Bram@vim.org>
parents: 27944
diff changeset
1427 endfunc
3de9be15de51 patch 8.2.4502: in the GUI a modifier is not recognized after CTRL-X
Bram Moolenaar <Bram@vim.org>
parents: 27944
diff changeset
1428
3de9be15de51 patch 8.2.4502: in the GUI a modifier is not recognized after CTRL-X
Bram Moolenaar <Bram@vim.org>
parents: 27944
diff changeset
1429 " A mapping is not used for the key after CTRL-X.
3de9be15de51 patch 8.2.4502: in the GUI a modifier is not recognized after CTRL-X
Bram Moolenaar <Bram@vim.org>
parents: 27944
diff changeset
1430 func Test_no_mapping_for_ctrl_x_key()
3de9be15de51 patch 8.2.4502: in the GUI a modifier is not recognized after CTRL-X
Bram Moolenaar <Bram@vim.org>
parents: 27944
diff changeset
1431 new
30473
1928947b8e1a patch 9.0.0572: insert complete tests leave a mapping behind
Bram Moolenaar <Bram@vim.org>
parents: 30463
diff changeset
1432 inoremap <buffer> <C-K> <Cmd>let was_mapped = 'yes'<CR>
27954
3de9be15de51 patch 8.2.4502: in the GUI a modifier is not recognized after CTRL-X
Bram Moolenaar <Bram@vim.org>
parents: 27944
diff changeset
1433 setlocal dictionary=README.txt
3de9be15de51 patch 8.2.4502: in the GUI a modifier is not recognized after CTRL-X
Bram Moolenaar <Bram@vim.org>
parents: 27944
diff changeset
1434 call feedkeys("aexam\<C-X>\<C-K> ", 'xt')
3de9be15de51 patch 8.2.4502: in the GUI a modifier is not recognized after CTRL-X
Bram Moolenaar <Bram@vim.org>
parents: 27944
diff changeset
1435 call assert_equal('example ', getline(1))
3de9be15de51 patch 8.2.4502: in the GUI a modifier is not recognized after CTRL-X
Bram Moolenaar <Bram@vim.org>
parents: 27944
diff changeset
1436 call assert_false(exists('was_mapped'))
3de9be15de51 patch 8.2.4502: in the GUI a modifier is not recognized after CTRL-X
Bram Moolenaar <Bram@vim.org>
parents: 27944
diff changeset
1437 bwipe!
23169
5e6855ebc4ea patch 8.2.2130: Insert mode completion messages end up in message history
Bram Moolenaar <Bram@vim.org>
parents: 22717
diff changeset
1438 endfunc
5e6855ebc4ea patch 8.2.2130: Insert mode completion messages end up in message history
Bram Moolenaar <Bram@vim.org>
parents: 22717
diff changeset
1439
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1440 " Test for different ways of setting the 'completefunc' option
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1441 func Test_completefunc_callback()
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1442 func CompleteFunc1(callnr, findstart, base)
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1443 call add(g:CompleteFunc1Args, [a:callnr, a:findstart, a:base])
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1444 return a:findstart ? 0 : []
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1445 endfunc
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1446 func CompleteFunc2(findstart, base)
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1447 call add(g:CompleteFunc2Args, [a:findstart, a:base])
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1448 return a:findstart ? 0 : []
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1449 endfunc
26456
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1450
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1451 let lines =<< trim END
26618
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1452 #" Test for using a global function name
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1453 LET &completefunc = 'g:CompleteFunc2'
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1454 new
26618
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1455 call setline(1, 'global')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1456 LET g:CompleteFunc2Args = []
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1457 call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
26618
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1458 call assert_equal([[1, ''], [0, 'global']], g:CompleteFunc2Args)
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1459 bw!
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1460
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1461 #" Test for using a function()
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1462 set completefunc=function('g:CompleteFunc1',\ [10])
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1463 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1464 call setline(1, 'one')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1465 LET g:CompleteFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1466 call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1467 call assert_equal([[10, 1, ''], [10, 0, 'one']], g:CompleteFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1468 bw!
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1469
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1470 #" Using a funcref variable to set 'completefunc'
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1471 VAR Fn = function('g:CompleteFunc1', [11])
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1472 LET &completefunc = Fn
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1473 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1474 call setline(1, 'two')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1475 LET g:CompleteFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1476 call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1477 call assert_equal([[11, 1, ''], [11, 0, 'two']], g:CompleteFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1478 bw!
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1479
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1480 #" Using string(funcref_variable) to set 'completefunc'
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1481 LET Fn = function('g:CompleteFunc1', [12])
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1482 LET &completefunc = string(Fn)
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1483 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1484 call setline(1, 'two')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1485 LET g:CompleteFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1486 call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1487 call assert_equal([[12, 1, ''], [12, 0, 'two']], g:CompleteFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1488 bw!
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1489
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1490 #" Test for using a funcref()
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1491 set completefunc=funcref('g:CompleteFunc1',\ [13])
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1492 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1493 call setline(1, 'three')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1494 LET g:CompleteFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1495 call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1496 call assert_equal([[13, 1, ''], [13, 0, 'three']], g:CompleteFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1497 bw!
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1498
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1499 #" Using a funcref variable to set 'completefunc'
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1500 LET Fn = funcref('g:CompleteFunc1', [14])
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1501 LET &completefunc = Fn
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1502 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1503 call setline(1, 'four')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1504 LET g:CompleteFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1505 call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1506 call assert_equal([[14, 1, ''], [14, 0, 'four']], g:CompleteFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1507 bw!
26441
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26408
diff changeset
1508
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1509 #" Using a string(funcref_variable) to set 'completefunc'
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1510 LET Fn = funcref('g:CompleteFunc1', [15])
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1511 LET &completefunc = string(Fn)
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1512 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1513 call setline(1, 'four')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1514 LET g:CompleteFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1515 call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1516 call assert_equal([[15, 1, ''], [15, 0, 'four']], g:CompleteFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1517 bw!
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1518
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1519 #" Test for using a lambda function with set
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27016
diff changeset
1520 VAR optval = "LSTART a, b LMIDDLE g:CompleteFunc1(16, a, b) LEND"
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1521 LET optval = substitute(optval, ' ', '\\ ', 'g')
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1522 exe "set completefunc=" .. optval
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1523 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1524 call setline(1, 'five')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1525 LET g:CompleteFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1526 call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1527 call assert_equal([[16, 1, ''], [16, 0, 'five']], g:CompleteFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1528 bw!
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1529
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1530 #" Set 'completefunc' to a lambda expression
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27016
diff changeset
1531 LET &completefunc = LSTART a, b LMIDDLE g:CompleteFunc1(17, a, b) LEND
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1532 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1533 call setline(1, 'six')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1534 LET g:CompleteFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1535 call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1536 call assert_equal([[17, 1, ''], [17, 0, 'six']], g:CompleteFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1537 bw!
26441
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26408
diff changeset
1538
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1539 #" Set 'completefunc' to string(lambda_expression)
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27016
diff changeset
1540 LET &completefunc = 'LSTART a, b LMIDDLE g:CompleteFunc1(18, a, b) LEND'
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1541 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1542 call setline(1, 'six')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1543 LET g:CompleteFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1544 call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1545 call assert_equal([[18, 1, ''], [18, 0, 'six']], g:CompleteFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1546 bw!
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1547
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1548 #" Set 'completefunc' to a variable with a lambda expression
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27016
diff changeset
1549 VAR Lambda = LSTART a, b LMIDDLE g:CompleteFunc1(19, a, b) LEND
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1550 LET &completefunc = Lambda
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1551 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1552 call setline(1, 'seven')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1553 LET g:CompleteFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1554 call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1555 call assert_equal([[19, 1, ''], [19, 0, 'seven']], g:CompleteFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1556 bw!
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1557
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1558 #" Set 'completefunc' to a string(variable with a lambda expression)
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27016
diff changeset
1559 LET Lambda = LSTART a, b LMIDDLE g:CompleteFunc1(20, a, b) LEND
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1560 LET &completefunc = string(Lambda)
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1561 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1562 call setline(1, 'seven')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1563 LET g:CompleteFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1564 call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1565 call assert_equal([[20, 1, ''], [20, 0, 'seven']], g:CompleteFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1566 bw!
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1567
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1568 #" Test for using a lambda function with incorrect return value
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1569 LET Lambda = LSTART a, b LMIDDLE strlen(a) LEND
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1570 LET &completefunc = Lambda
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1571 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1572 call setline(1, 'eight')
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1573 call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1574 bw!
26441
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26408
diff changeset
1575
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1576 #" Test for clearing the 'completefunc' option
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1577 set completefunc=''
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1578 set completefunc&
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1579 call assert_fails("set completefunc=function('abc')", "E700:")
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1580 call assert_fails("set completefunc=funcref('abc')", "E700:")
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1581
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1582 #" set 'completefunc' to a non-existing function
27464
a14c4d3e3260 patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
1583 set completefunc=g:CompleteFunc2
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1584 call setline(1, 'five')
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1585 call assert_fails("set completefunc=function('NonExistingFunc')", 'E700:')
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1586 call assert_fails("LET &completefunc = function('NonExistingFunc')", 'E700:')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1587 LET g:CompleteFunc2Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1588 call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1589 call assert_equal([[1, ''], [0, 'five']], g:CompleteFunc2Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1590 bw!
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1591 END
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27016
diff changeset
1592 call v9.CheckLegacyAndVim9Success(lines)
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1593
26618
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1594 " Test for using a script-local function name
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1595 func s:CompleteFunc3(findstart, base)
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1596 call add(g:CompleteFunc3Args, [a:findstart, a:base])
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1597 return a:findstart ? 0 : []
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1598 endfunc
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1599 set completefunc=s:CompleteFunc3
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1600 new
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1601 call setline(1, 'script1')
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1602 let g:CompleteFunc3Args = []
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1603 call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1604 call assert_equal([[1, ''], [0, 'script1']], g:CompleteFunc3Args)
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1605 bw!
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1606
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1607 let &completefunc = 's:CompleteFunc3'
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1608 new
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1609 call setline(1, 'script2')
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1610 let g:CompleteFunc3Args = []
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1611 call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1612 call assert_equal([[1, ''], [0, 'script2']], g:CompleteFunc3Args)
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1613 bw!
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1614 delfunc s:CompleteFunc3
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1615
27780
f1d5822ca0d7 patch 8.2.4416: Vim9: using a script-local function requires using "s:"
Bram Moolenaar <Bram@vim.org>
parents: 27671
diff changeset
1616 " In Vim9 script s: can be omitted
f1d5822ca0d7 patch 8.2.4416: Vim9: using a script-local function requires using "s:"
Bram Moolenaar <Bram@vim.org>
parents: 27671
diff changeset
1617 let lines =<< trim END
f1d5822ca0d7 patch 8.2.4416: Vim9: using a script-local function requires using "s:"
Bram Moolenaar <Bram@vim.org>
parents: 27671
diff changeset
1618 vim9script
f1d5822ca0d7 patch 8.2.4416: Vim9: using a script-local function requires using "s:"
Bram Moolenaar <Bram@vim.org>
parents: 27671
diff changeset
1619 var CompleteFunc4Args = []
f1d5822ca0d7 patch 8.2.4416: Vim9: using a script-local function requires using "s:"
Bram Moolenaar <Bram@vim.org>
parents: 27671
diff changeset
1620 def CompleteFunc4(findstart: bool, base: string): any
f1d5822ca0d7 patch 8.2.4416: Vim9: using a script-local function requires using "s:"
Bram Moolenaar <Bram@vim.org>
parents: 27671
diff changeset
1621 add(CompleteFunc4Args, [findstart, base])
f1d5822ca0d7 patch 8.2.4416: Vim9: using a script-local function requires using "s:"
Bram Moolenaar <Bram@vim.org>
parents: 27671
diff changeset
1622 return findstart ? 0 : []
f1d5822ca0d7 patch 8.2.4416: Vim9: using a script-local function requires using "s:"
Bram Moolenaar <Bram@vim.org>
parents: 27671
diff changeset
1623 enddef
f1d5822ca0d7 patch 8.2.4416: Vim9: using a script-local function requires using "s:"
Bram Moolenaar <Bram@vim.org>
parents: 27671
diff changeset
1624 set completefunc=CompleteFunc4
f1d5822ca0d7 patch 8.2.4416: Vim9: using a script-local function requires using "s:"
Bram Moolenaar <Bram@vim.org>
parents: 27671
diff changeset
1625 new
f1d5822ca0d7 patch 8.2.4416: Vim9: using a script-local function requires using "s:"
Bram Moolenaar <Bram@vim.org>
parents: 27671
diff changeset
1626 setline(1, 'script1')
f1d5822ca0d7 patch 8.2.4416: Vim9: using a script-local function requires using "s:"
Bram Moolenaar <Bram@vim.org>
parents: 27671
diff changeset
1627 feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
f1d5822ca0d7 patch 8.2.4416: Vim9: using a script-local function requires using "s:"
Bram Moolenaar <Bram@vim.org>
parents: 27671
diff changeset
1628 assert_equal([[1, ''], [0, 'script1']], CompleteFunc4Args)
f1d5822ca0d7 patch 8.2.4416: Vim9: using a script-local function requires using "s:"
Bram Moolenaar <Bram@vim.org>
parents: 27671
diff changeset
1629 bw!
f1d5822ca0d7 patch 8.2.4416: Vim9: using a script-local function requires using "s:"
Bram Moolenaar <Bram@vim.org>
parents: 27671
diff changeset
1630 END
f1d5822ca0d7 patch 8.2.4416: Vim9: using a script-local function requires using "s:"
Bram Moolenaar <Bram@vim.org>
parents: 27671
diff changeset
1631 call v9.CheckScriptSuccess(lines)
f1d5822ca0d7 patch 8.2.4416: Vim9: using a script-local function requires using "s:"
Bram Moolenaar <Bram@vim.org>
parents: 27671
diff changeset
1632
26618
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1633 " invalid return value
26441
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26408
diff changeset
1634 let &completefunc = {a -> 'abc'}
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1635 call feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1636
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1637 " Using Vim9 lambda expression in legacy context should fail
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27016
diff changeset
1638 set completefunc=(a,\ b)\ =>\ g:CompleteFunc1(21,\ a,\ b)
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1639 new | only
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1640 let g:CompleteFunc1Args = []
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1641 call assert_fails('call feedkeys("A\<C-X>\<C-U>\<Esc>", "x")', 'E117:')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1642 call assert_equal([], g:CompleteFunc1Args)
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1643
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1644 " set 'completefunc' to a partial with dict. This used to cause a crash.
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1645 func SetCompleteFunc()
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1646 let params = {'complete': function('g:DictCompleteFunc')}
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1647 let &completefunc = params.complete
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1648 endfunc
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1649 func g:DictCompleteFunc(_) dict
26456
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1650 endfunc
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1651 call SetCompleteFunc()
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1652 new
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1653 call SetCompleteFunc()
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1654 bw
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1655 call test_garbagecollect_now()
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1656 new
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1657 set completefunc=
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1658 wincmd w
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1659 set completefunc=
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1660 %bw!
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1661 delfunc g:DictCompleteFunc
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1662 delfunc SetCompleteFunc
26456
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1663
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1664 " Vim9 tests
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1665 let lines =<< trim END
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1666 vim9script
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1667
26618
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1668 def Vim9CompleteFunc(callnr: number, findstart: number, base: string): any
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1669 add(g:Vim9completeFuncArgs, [callnr, findstart, base])
26456
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1670 return findstart ? 0 : []
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1671 enddef
26618
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1672
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1673 # Test for using a def function with completefunc
26456
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1674 set completefunc=function('Vim9CompleteFunc',\ [60])
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1675 new | only
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1676 setline(1, 'one')
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1677 g:Vim9completeFuncArgs = []
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1678 feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1679 assert_equal([[60, 1, ''], [60, 0, 'one']], g:Vim9completeFuncArgs)
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1680 bw!
26618
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1681
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1682 # Test for using a global function name
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1683 &completefunc = g:CompleteFunc2
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1684 new | only
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1685 setline(1, 'two')
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1686 g:CompleteFunc2Args = []
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1687 feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1688 assert_equal([[1, ''], [0, 'two']], g:CompleteFunc2Args)
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1689 bw!
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1690
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1691 # Test for using a script-local function name
27671
19367412787c patch 8.2.4361: Vim9: some tests fail
Bram Moolenaar <Bram@vim.org>
parents: 27474
diff changeset
1692 def LocalCompleteFunc(findstart: number, base: string): any
26618
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1693 add(g:LocalCompleteFuncArgs, [findstart, base])
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1694 return findstart ? 0 : []
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1695 enddef
27671
19367412787c patch 8.2.4361: Vim9: some tests fail
Bram Moolenaar <Bram@vim.org>
parents: 27474
diff changeset
1696 &completefunc = LocalCompleteFunc
26618
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1697 new | only
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1698 setline(1, 'three')
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1699 g:LocalCompleteFuncArgs = []
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1700 feedkeys("A\<C-X>\<C-U>\<Esc>", 'x')
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1701 assert_equal([[1, ''], [0, 'three']], g:LocalCompleteFuncArgs)
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1702 bw!
26456
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1703 END
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27016
diff changeset
1704 call v9.CheckScriptSuccess(lines)
26452
65b4109a4297 patch 8.2.3756: might crash when callback is not valid
Bram Moolenaar <Bram@vim.org>
parents: 26441
diff changeset
1705
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1706 " cleanup
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1707 set completefunc&
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1708 delfunc CompleteFunc1
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1709 delfunc CompleteFunc2
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1710 unlet g:CompleteFunc1Args g:CompleteFunc2Args
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1711 %bw!
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1712 endfunc
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1713
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1714 " Test for different ways of setting the 'omnifunc' option
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1715 func Test_omnifunc_callback()
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1716 func OmniFunc1(callnr, findstart, base)
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1717 call add(g:OmniFunc1Args, [a:callnr, a:findstart, a:base])
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1718 return a:findstart ? 0 : []
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1719 endfunc
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1720 func OmniFunc2(findstart, base)
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1721 call add(g:OmniFunc2Args, [a:findstart, a:base])
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1722 return a:findstart ? 0 : []
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1723 endfunc
26456
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1724
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1725 let lines =<< trim END
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1726 #" Test for using a function name
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1727 LET &omnifunc = 'g:OmniFunc2'
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1728 new
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1729 call setline(1, 'zero')
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1730 LET g:OmniFunc2Args = []
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1731 call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1732 call assert_equal([[1, ''], [0, 'zero']], g:OmniFunc2Args)
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1733 bw!
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1734
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1735 #" Test for using a function()
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1736 set omnifunc=function('g:OmniFunc1',\ [10])
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1737 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1738 call setline(1, 'one')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1739 LET g:OmniFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1740 call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1741 call assert_equal([[10, 1, ''], [10, 0, 'one']], g:OmniFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1742 bw!
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1743
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1744 #" Using a funcref variable to set 'omnifunc'
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1745 VAR Fn = function('g:OmniFunc1', [11])
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1746 LET &omnifunc = Fn
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1747 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1748 call setline(1, 'two')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1749 LET g:OmniFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1750 call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1751 call assert_equal([[11, 1, ''], [11, 0, 'two']], g:OmniFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1752 bw!
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1753
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1754 #" Using a string(funcref_variable) to set 'omnifunc'
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1755 LET Fn = function('g:OmniFunc1', [12])
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1756 LET &omnifunc = string(Fn)
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1757 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1758 call setline(1, 'two')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1759 LET g:OmniFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1760 call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1761 call assert_equal([[12, 1, ''], [12, 0, 'two']], g:OmniFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1762 bw!
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1763
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1764 #" Test for using a funcref()
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1765 set omnifunc=funcref('g:OmniFunc1',\ [13])
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1766 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1767 call setline(1, 'three')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1768 LET g:OmniFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1769 call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1770 call assert_equal([[13, 1, ''], [13, 0, 'three']], g:OmniFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1771 bw!
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1772
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1773 #" Use let to set 'omnifunc' to a funcref
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1774 LET Fn = funcref('g:OmniFunc1', [14])
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1775 LET &omnifunc = Fn
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1776 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1777 call setline(1, 'four')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1778 LET g:OmniFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1779 call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1780 call assert_equal([[14, 1, ''], [14, 0, 'four']], g:OmniFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1781 bw!
26441
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26408
diff changeset
1782
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1783 #" Using a string(funcref) to set 'omnifunc'
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1784 LET Fn = funcref("g:OmniFunc1", [15])
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1785 LET &omnifunc = string(Fn)
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1786 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1787 call setline(1, 'four')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1788 LET g:OmniFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1789 call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1790 call assert_equal([[15, 1, ''], [15, 0, 'four']], g:OmniFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1791 bw!
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1792
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1793 #" Test for using a lambda function with set
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27016
diff changeset
1794 VAR optval = "LSTART a, b LMIDDLE g:OmniFunc1(16, a, b) LEND"
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1795 LET optval = substitute(optval, ' ', '\\ ', 'g')
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1796 exe "set omnifunc=" .. optval
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1797 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1798 call setline(1, 'five')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1799 LET g:OmniFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1800 call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1801 call assert_equal([[16, 1, ''], [16, 0, 'five']], g:OmniFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1802 bw!
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1803
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1804 #" Set 'omnifunc' to a lambda expression
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27016
diff changeset
1805 LET &omnifunc = LSTART a, b LMIDDLE g:OmniFunc1(17, a, b) LEND
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1806 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1807 call setline(1, 'six')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1808 LET g:OmniFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1809 call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1810 call assert_equal([[17, 1, ''], [17, 0, 'six']], g:OmniFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1811 bw!
26441
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26408
diff changeset
1812
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1813 #" Set 'omnifunc' to a string(lambda_expression)
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27016
diff changeset
1814 LET &omnifunc = 'LSTART a, b LMIDDLE g:OmniFunc1(18, a, b) LEND'
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1815 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1816 call setline(1, 'six')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1817 LET g:OmniFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1818 call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1819 call assert_equal([[18, 1, ''], [18, 0, 'six']], g:OmniFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1820 bw!
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1821
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1822 #" Set 'omnifunc' to a variable with a lambda expression
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27016
diff changeset
1823 VAR Lambda = LSTART a, b LMIDDLE g:OmniFunc1(19, a, b) LEND
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1824 LET &omnifunc = Lambda
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1825 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1826 call setline(1, 'seven')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1827 LET g:OmniFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1828 call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1829 call assert_equal([[19, 1, ''], [19, 0, 'seven']], g:OmniFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1830 bw!
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1831
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1832 #" Set 'omnifunc' to a string(variable with a lambda expression)
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27016
diff changeset
1833 LET Lambda = LSTART a, b LMIDDLE g:OmniFunc1(20, a, b) LEND
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1834 LET &omnifunc = string(Lambda)
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1835 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1836 call setline(1, 'seven')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1837 LET g:OmniFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1838 call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1839 call assert_equal([[20, 1, ''], [20, 0, 'seven']], g:OmniFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1840 bw!
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1841
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1842 #" Test for using a lambda function with incorrect return value
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1843 LET Lambda = LSTART a, b LMIDDLE strlen(a) LEND
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1844 LET &omnifunc = Lambda
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1845 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1846 call setline(1, 'eight')
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1847 call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1848 bw!
26441
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26408
diff changeset
1849
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1850 #" Test for clearing the 'omnifunc' option
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1851 set omnifunc=''
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1852 set omnifunc&
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1853 call assert_fails("set omnifunc=function('abc')", "E700:")
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1854 call assert_fails("set omnifunc=funcref('abc')", "E700:")
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1855
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1856 #" set 'omnifunc' to a non-existing function
27464
a14c4d3e3260 patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
1857 set omnifunc=g:OmniFunc2
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1858 call setline(1, 'nine')
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1859 call assert_fails("set omnifunc=function('NonExistingFunc')", 'E700:')
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1860 call assert_fails("LET &omnifunc = function('NonExistingFunc')", 'E700:')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1861 LET g:OmniFunc2Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1862 call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1863 call assert_equal([[1, ''], [0, 'nine']], g:OmniFunc2Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1864 bw!
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1865 END
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27016
diff changeset
1866 call v9.CheckLegacyAndVim9Success(lines)
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1867
26618
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1868 " Test for using a script-local function name
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1869 func s:OmniFunc3(findstart, base)
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1870 call add(g:OmniFunc3Args, [a:findstart, a:base])
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1871 return a:findstart ? 0 : []
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1872 endfunc
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1873 set omnifunc=s:OmniFunc3
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1874 new
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1875 call setline(1, 'script1')
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1876 let g:OmniFunc3Args = []
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1877 call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1878 call assert_equal([[1, ''], [0, 'script1']], g:OmniFunc3Args)
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1879 bw!
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1880
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1881 let &omnifunc = 's:OmniFunc3'
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1882 new
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1883 call setline(1, 'script2')
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1884 let g:OmniFunc3Args = []
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1885 call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1886 call assert_equal([[1, ''], [0, 'script2']], g:OmniFunc3Args)
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1887 bw!
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1888 delfunc s:OmniFunc3
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1889
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1890 " invalid return value
26441
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26408
diff changeset
1891 let &omnifunc = {a -> 'abc'}
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1892 call feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1893
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1894 " Using Vim9 lambda expression in legacy context should fail
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1895 set omnifunc=(a,\ b)\ =>\ OmniFunc1(21,\ a,\ b)
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1896 new | only
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1897 let g:OmniFunc1Args = []
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1898 call assert_fails('call feedkeys("A\<C-X>\<C-O>\<Esc>", "x")', 'E117:')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1899 call assert_equal([], g:OmniFunc1Args)
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1900
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1901 " set 'omnifunc' to a partial with dict. This used to cause a crash.
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1902 func SetOmniFunc()
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1903 let params = {'omni': function('g:DictOmniFunc')}
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1904 let &omnifunc = params.omni
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1905 endfunc
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1906 func g:DictOmniFunc(_) dict
26456
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1907 endfunc
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1908 call SetOmniFunc()
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1909 new
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1910 call SetOmniFunc()
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1911 bw
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1912 call test_garbagecollect_now()
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1913 new
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1914 set omnifunc=
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1915 wincmd w
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1916 set omnifunc=
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1917 %bw!
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1918 delfunc g:DictOmniFunc
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1919 delfunc SetOmniFunc
26456
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1920
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1921 " Vim9 tests
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1922 let lines =<< trim END
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1923 vim9script
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1924
26618
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1925 def Vim9omniFunc(callnr: number, findstart: number, base: string): any
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1926 add(g:Vim9omniFunc_Args, [callnr, findstart, base])
26456
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1927 return findstart ? 0 : []
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1928 enddef
26618
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1929
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1930 # Test for using a def function with omnifunc
26456
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1931 set omnifunc=function('Vim9omniFunc',\ [60])
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1932 new | only
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1933 setline(1, 'one')
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1934 g:Vim9omniFunc_Args = []
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1935 feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1936 assert_equal([[60, 1, ''], [60, 0, 'one']], g:Vim9omniFunc_Args)
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1937 bw!
26618
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1938
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1939 # Test for using a global function name
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1940 &omnifunc = g:OmniFunc2
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1941 new | only
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1942 setline(1, 'two')
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1943 g:OmniFunc2Args = []
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1944 feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1945 assert_equal([[1, ''], [0, 'two']], g:OmniFunc2Args)
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1946 bw!
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1947
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1948 # Test for using a script-local function name
27671
19367412787c patch 8.2.4361: Vim9: some tests fail
Bram Moolenaar <Bram@vim.org>
parents: 27474
diff changeset
1949 def LocalOmniFunc(findstart: number, base: string): any
26618
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1950 add(g:LocalOmniFuncArgs, [findstart, base])
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1951 return findstart ? 0 : []
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1952 enddef
27671
19367412787c patch 8.2.4361: Vim9: some tests fail
Bram Moolenaar <Bram@vim.org>
parents: 27474
diff changeset
1953 &omnifunc = LocalOmniFunc
26618
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1954 new | only
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1955 setline(1, 'three')
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1956 g:LocalOmniFuncArgs = []
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1957 feedkeys("A\<C-X>\<C-O>\<Esc>", 'x')
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1958 assert_equal([[1, ''], [0, 'three']], g:LocalOmniFuncArgs)
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
1959 bw!
26456
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1960 END
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27016
diff changeset
1961 call v9.CheckScriptSuccess(lines)
26452
65b4109a4297 patch 8.2.3756: might crash when callback is not valid
Bram Moolenaar <Bram@vim.org>
parents: 26441
diff changeset
1962
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1963 " cleanup
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1964 set omnifunc&
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1965 delfunc OmniFunc1
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1966 delfunc OmniFunc2
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1967 unlet g:OmniFunc1Args g:OmniFunc2Args
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1968 %bw!
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1969 endfunc
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1970
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1971 " Test for different ways of setting the 'thesaurusfunc' option
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1972 func Test_thesaurusfunc_callback()
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1973 func TsrFunc1(callnr, findstart, base)
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1974 call add(g:TsrFunc1Args, [a:callnr, a:findstart, a:base])
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1975 return a:findstart ? 0 : []
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
1976 endfunc
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1977 func TsrFunc2(findstart, base)
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1978 call add(g:TsrFunc2Args, [a:findstart, a:base])
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1979 return a:findstart ? 0 : ['sunday']
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1980 endfunc
26456
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
1981
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1982 let lines =<< trim END
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1983 #" Test for using a function name
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1984 LET &thesaurusfunc = 'g:TsrFunc2'
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1985 new
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1986 call setline(1, 'zero')
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1987 LET g:TsrFunc2Args = []
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1988 call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1989 call assert_equal([[1, ''], [0, 'zero']], g:TsrFunc2Args)
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1990 bw!
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1991
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1992 #" Test for using a function()
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1993 set thesaurusfunc=function('g:TsrFunc1',\ [10])
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1994 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1995 call setline(1, 'one')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1996 LET g:TsrFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1997 call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
1998 call assert_equal([[10, 1, ''], [10, 0, 'one']], g:TsrFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
1999 bw!
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
2000
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2001 #" Using a funcref variable to set 'thesaurusfunc'
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2002 VAR Fn = function('g:TsrFunc1', [11])
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2003 LET &thesaurusfunc = Fn
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2004 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2005 call setline(1, 'two')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2006 LET g:TsrFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2007 call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2008 call assert_equal([[11, 1, ''], [11, 0, 'two']], g:TsrFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2009 bw!
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2010
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2011 #" Using a string(funcref_variable) to set 'thesaurusfunc'
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2012 LET Fn = function('g:TsrFunc1', [12])
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2013 LET &thesaurusfunc = string(Fn)
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2014 new
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2015 call setline(1, 'two')
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2016 LET g:TsrFunc1Args = []
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2017 call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2018 call assert_equal([[12, 1, ''], [12, 0, 'two']], g:TsrFunc1Args)
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2019 bw!
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2020
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2021 #" Test for using a funcref()
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2022 set thesaurusfunc=funcref('g:TsrFunc1',\ [13])
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2023 new
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2024 call setline(1, 'three')
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2025 LET g:TsrFunc1Args = []
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2026 call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2027 call assert_equal([[13, 1, ''], [13, 0, 'three']], g:TsrFunc1Args)
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2028 bw!
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2029
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2030 #" Using a funcref variable to set 'thesaurusfunc'
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2031 LET Fn = funcref('g:TsrFunc1', [14])
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2032 LET &thesaurusfunc = Fn
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2033 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2034 call setline(1, 'four')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2035 LET g:TsrFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2036 call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2037 call assert_equal([[14, 1, ''], [14, 0, 'four']], g:TsrFunc1Args)
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2038 bw!
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2039
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2040 #" Using a string(funcref_variable) to set 'thesaurusfunc'
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2041 LET Fn = funcref('g:TsrFunc1', [15])
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2042 LET &thesaurusfunc = string(Fn)
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2043 new
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2044 call setline(1, 'four')
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2045 LET g:TsrFunc1Args = []
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2046 call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2047 call assert_equal([[15, 1, ''], [15, 0, 'four']], g:TsrFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2048 bw!
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
2049
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2050 #" Test for using a lambda function
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27016
diff changeset
2051 VAR optval = "LSTART a, b LMIDDLE g:TsrFunc1(16, a, b) LEND"
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2052 LET optval = substitute(optval, ' ', '\\ ', 'g')
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2053 exe "set thesaurusfunc=" .. optval
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2054 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2055 call setline(1, 'five')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2056 LET g:TsrFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2057 call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2058 call assert_equal([[16, 1, ''], [16, 0, 'five']], g:TsrFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2059 bw!
26441
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26408
diff changeset
2060
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2061 #" Test for using a lambda function with set
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27016
diff changeset
2062 LET &thesaurusfunc = LSTART a, b LMIDDLE g:TsrFunc1(17, a, b) LEND
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2063 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2064 call setline(1, 'six')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2065 LET g:TsrFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2066 call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2067 call assert_equal([[17, 1, ''], [17, 0, 'six']], g:TsrFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2068 bw!
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
2069
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2070 #" Set 'thesaurusfunc' to a string(lambda expression)
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27016
diff changeset
2071 LET &thesaurusfunc = 'LSTART a, b LMIDDLE g:TsrFunc1(18, a, b) LEND'
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2072 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2073 call setline(1, 'six')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2074 LET g:TsrFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2075 call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2076 call assert_equal([[18, 1, ''], [18, 0, 'six']], g:TsrFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2077 bw!
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
2078
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2079 #" Set 'thesaurusfunc' to a variable with a lambda expression
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27016
diff changeset
2080 VAR Lambda = LSTART a, b LMIDDLE g:TsrFunc1(19, a, b) LEND
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2081 LET &thesaurusfunc = Lambda
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2082 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2083 call setline(1, 'seven')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2084 LET g:TsrFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2085 call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2086 call assert_equal([[19, 1, ''], [19, 0, 'seven']], g:TsrFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2087 bw!
26441
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26408
diff changeset
2088
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2089 #" Set 'thesaurusfunc' to a string(variable with a lambda expression)
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27016
diff changeset
2090 LET Lambda = LSTART a, b LMIDDLE g:TsrFunc1(20, a, b) LEND
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2091 LET &thesaurusfunc = string(Lambda)
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2092 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2093 call setline(1, 'seven')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2094 LET g:TsrFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2095 call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2096 call assert_equal([[20, 1, ''], [20, 0, 'seven']], g:TsrFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2097 bw!
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2098
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2099 #" Test for using a lambda function with incorrect return value
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2100 LET Lambda = LSTART a, b LMIDDLE strlen(a) LEND
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2101 LET &thesaurusfunc = Lambda
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2102 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2103 call setline(1, 'eight')
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2104 call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2105 bw!
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
2106
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2107 #" Test for clearing the 'thesaurusfunc' option
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2108 set thesaurusfunc=''
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2109 set thesaurusfunc&
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2110 call assert_fails("set thesaurusfunc=function('abc')", "E700:")
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2111 call assert_fails("set thesaurusfunc=funcref('abc')", "E700:")
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2112
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2113 #" set 'thesaurusfunc' to a non-existing function
27464
a14c4d3e3260 patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents: 27457
diff changeset
2114 set thesaurusfunc=g:TsrFunc2
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2115 call setline(1, 'ten')
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2116 call assert_fails("set thesaurusfunc=function('NonExistingFunc')", 'E700:')
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2117 call assert_fails("LET &thesaurusfunc = function('NonExistingFunc')", 'E700:')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2118 LET g:TsrFunc2Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2119 call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2120 call assert_equal([[1, ''], [0, 'ten']], g:TsrFunc2Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2121 bw!
26441
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26408
diff changeset
2122
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2123 #" Use a buffer-local value and a global value
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2124 set thesaurusfunc&
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2125 setlocal thesaurusfunc=function('g:TsrFunc1',\ [22])
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2126 call setline(1, 'sun')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2127 LET g:TsrFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2128 call feedkeys("A\<C-X>\<C-T>\<Esc>", "x")
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2129 call assert_equal('sun', getline(1))
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2130 call assert_equal([[22, 1, ''], [22, 0, 'sun']], g:TsrFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2131 new
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2132 call setline(1, 'sun')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2133 LET g:TsrFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2134 call feedkeys("A\<C-X>\<C-T>\<Esc>", "x")
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2135 call assert_equal('sun', getline(1))
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2136 call assert_equal([], g:TsrFunc1Args)
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2137 set thesaurusfunc=function('g:TsrFunc1',\ [23])
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2138 wincmd w
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2139 call setline(1, 'sun')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2140 LET g:TsrFunc1Args = []
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2141 call feedkeys("A\<C-X>\<C-T>\<Esc>", "x")
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2142 call assert_equal('sun', getline(1))
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2143 call assert_equal([[22, 1, ''], [22, 0, 'sun']], g:TsrFunc1Args)
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2144 :%bw!
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2145 END
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27016
diff changeset
2146 call v9.CheckLegacyAndVim9Success(lines)
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
2147
26618
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2148 " Test for using a script-local function name
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2149 func s:TsrFunc3(findstart, base)
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2150 call add(g:TsrFunc3Args, [a:findstart, a:base])
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2151 return a:findstart ? 0 : []
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2152 endfunc
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2153 set tsrfu=s:TsrFunc3
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2154 new
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2155 call setline(1, 'script1')
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2156 let g:TsrFunc3Args = []
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2157 call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2158 call assert_equal([[1, ''], [0, 'script1']], g:TsrFunc3Args)
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2159 bw!
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2160
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2161 let &tsrfu = 's:TsrFunc3'
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2162 new
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2163 call setline(1, 'script2')
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2164 let g:TsrFunc3Args = []
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2165 call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2166 call assert_equal([[1, ''], [0, 'script2']], g:TsrFunc3Args)
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2167 bw!
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2168 delfunc s:TsrFunc3
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2169
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2170 " invalid return value
26441
65ab0b035dd8 patch 8.2.3751: cannot assign a lambda to an option that takes a function
Bram Moolenaar <Bram@vim.org>
parents: 26408
diff changeset
2171 let &thesaurusfunc = {a -> 'abc'}
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
2172 call feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
2173
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
2174 " Using Vim9 lambda expression in legacy context should fail
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2175 set thesaurusfunc=(a,\ b)\ =>\ TsrFunc1(21,\ a,\ b)
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
2176 new | only
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2177 let g:TsrFunc1Args = []
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
2178 call assert_fails('call feedkeys("A\<C-X>\<C-T>\<Esc>", "x")', 'E117:')
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2179 call assert_equal([], g:TsrFunc1Args)
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
2180 bw!
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
2181
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2182 " set 'thesaurusfunc' to a partial with dict. This used to cause a crash.
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2183 func SetTsrFunc()
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2184 let params = {'thesaurus': function('g:DictTsrFunc')}
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2185 let &thesaurusfunc = params.thesaurus
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2186 endfunc
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2187 func g:DictTsrFunc(_) dict
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2188 endfunc
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2189 call SetTsrFunc()
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
2190 new
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2191 call SetTsrFunc()
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2192 bw
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2193 call test_garbagecollect_now()
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2194 new
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2195 set thesaurusfunc=
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
2196 wincmd w
26452
65b4109a4297 patch 8.2.3756: might crash when callback is not valid
Bram Moolenaar <Bram@vim.org>
parents: 26441
diff changeset
2197 %bw!
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2198 delfunc SetTsrFunc
26452
65b4109a4297 patch 8.2.3756: might crash when callback is not valid
Bram Moolenaar <Bram@vim.org>
parents: 26441
diff changeset
2199
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2200 " set buffer-local 'thesaurusfunc' to a partial with dict. This used to
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2201 " cause a crash.
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2202 func SetLocalTsrFunc()
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2203 let params = {'thesaurus': function('g:DictTsrFunc')}
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2204 let &l:thesaurusfunc = params.thesaurus
26456
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
2205 endfunc
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2206 call SetLocalTsrFunc()
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2207 call test_garbagecollect_now()
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2208 call SetLocalTsrFunc()
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2209 set thesaurusfunc=
26456
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
2210 bw!
26518
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2211 delfunc g:DictTsrFunc
13ba00ef7687 patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents: 26456
diff changeset
2212 delfunc SetLocalTsrFunc
26456
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
2213
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
2214 " Vim9 tests
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
2215 let lines =<< trim END
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
2216 vim9script
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
2217
26618
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2218 def Vim9tsrFunc(callnr: number, findstart: number, base: string): any
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2219 add(g:Vim9tsrFunc_Args, [callnr, findstart, base])
26456
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
2220 return findstart ? 0 : []
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
2221 enddef
26618
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2222
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2223 # Test for using a def function with thesaurusfunc
26456
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
2224 set thesaurusfunc=function('Vim9tsrFunc',\ [60])
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
2225 new | only
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
2226 setline(1, 'one')
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
2227 g:Vim9tsrFunc_Args = []
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
2228 feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
2229 assert_equal([[60, 1, ''], [60, 0, 'one']], g:Vim9tsrFunc_Args)
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
2230 bw!
26618
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2231
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2232 # Test for using a global function name
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2233 &thesaurusfunc = g:TsrFunc2
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2234 new | only
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2235 setline(1, 'two')
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2236 g:TsrFunc2Args = []
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2237 feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2238 assert_equal([[1, ''], [0, 'two']], g:TsrFunc2Args)
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2239 bw!
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2240
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2241 # Test for using a script-local function name
27671
19367412787c patch 8.2.4361: Vim9: some tests fail
Bram Moolenaar <Bram@vim.org>
parents: 27474
diff changeset
2242 def LocalTsrFunc(findstart: number, base: string): any
26618
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2243 add(g:LocalTsrFuncArgs, [findstart, base])
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2244 return findstart ? 0 : []
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2245 enddef
27671
19367412787c patch 8.2.4361: Vim9: some tests fail
Bram Moolenaar <Bram@vim.org>
parents: 27474
diff changeset
2246 &thesaurusfunc = LocalTsrFunc
26618
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2247 new | only
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2248 setline(1, 'three')
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2249 g:LocalTsrFuncArgs = []
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2250 feedkeys("A\<C-X>\<C-T>\<Esc>", 'x')
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2251 assert_equal([[1, ''], [0, 'three']], g:LocalTsrFuncArgs)
b531c26f728b patch 8.2.3838: cannot use script-local function for setting *func options
Bram Moolenaar <Bram@vim.org>
parents: 26526
diff changeset
2252 bw!
26456
7eaf61a67d18 patch 8.2.3758: options that take a function insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26452
diff changeset
2253 END
27457
4c16acb2525f patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 27016
diff changeset
2254 call v9.CheckScriptSuccess(lines)
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
2255
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
2256 " cleanup
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
2257 set thesaurusfunc&
26526
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2258 delfunc TsrFunc1
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2259 delfunc TsrFunc2
33d680d372aa patch 8.2.3792: setting *func options insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 26518
diff changeset
2260 unlet g:TsrFunc1Args g:TsrFunc2Args
26388
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
2261 %bw!
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
2262 endfunc
8aba638e91eb patch 8.2.3725: cannot use a lambda for 'completefunc' and 'omnifunc'
Bram Moolenaar <Bram@vim.org>
parents: 26211
diff changeset
2263
28369
38332c6da029 patch 8.2.4710: smart indenting does not work after completion
Bram Moolenaar <Bram@vim.org>
parents: 27954
diff changeset
2264 func FooBarComplete(findstart, base)
38332c6da029 patch 8.2.4710: smart indenting does not work after completion
Bram Moolenaar <Bram@vim.org>
parents: 27954
diff changeset
2265 if a:findstart
38332c6da029 patch 8.2.4710: smart indenting does not work after completion
Bram Moolenaar <Bram@vim.org>
parents: 27954
diff changeset
2266 return col('.') - 1
38332c6da029 patch 8.2.4710: smart indenting does not work after completion
Bram Moolenaar <Bram@vim.org>
parents: 27954
diff changeset
2267 else
38332c6da029 patch 8.2.4710: smart indenting does not work after completion
Bram Moolenaar <Bram@vim.org>
parents: 27954
diff changeset
2268 return ["Foo", "Bar", "}"]
38332c6da029 patch 8.2.4710: smart indenting does not work after completion
Bram Moolenaar <Bram@vim.org>
parents: 27954
diff changeset
2269 endif
38332c6da029 patch 8.2.4710: smart indenting does not work after completion
Bram Moolenaar <Bram@vim.org>
parents: 27954
diff changeset
2270 endfunc
38332c6da029 patch 8.2.4710: smart indenting does not work after completion
Bram Moolenaar <Bram@vim.org>
parents: 27954
diff changeset
2271
38332c6da029 patch 8.2.4710: smart indenting does not work after completion
Bram Moolenaar <Bram@vim.org>
parents: 27954
diff changeset
2272 func Test_complete_smartindent()
38332c6da029 patch 8.2.4710: smart indenting does not work after completion
Bram Moolenaar <Bram@vim.org>
parents: 27954
diff changeset
2273 new
38332c6da029 patch 8.2.4710: smart indenting does not work after completion
Bram Moolenaar <Bram@vim.org>
parents: 27954
diff changeset
2274 setlocal smartindent completefunc=FooBarComplete
38332c6da029 patch 8.2.4710: smart indenting does not work after completion
Bram Moolenaar <Bram@vim.org>
parents: 27954
diff changeset
2275
38332c6da029 patch 8.2.4710: smart indenting does not work after completion
Bram Moolenaar <Bram@vim.org>
parents: 27954
diff changeset
2276 exe "norm! o{\<cr>\<c-x>\<c-u>\<c-p>}\<cr>\<esc>"
38332c6da029 patch 8.2.4710: smart indenting does not work after completion
Bram Moolenaar <Bram@vim.org>
parents: 27954
diff changeset
2277 let result = getline(1,'$')
38332c6da029 patch 8.2.4710: smart indenting does not work after completion
Bram Moolenaar <Bram@vim.org>
parents: 27954
diff changeset
2278 call assert_equal(['', '{','}',''], result)
38332c6da029 patch 8.2.4710: smart indenting does not work after completion
Bram Moolenaar <Bram@vim.org>
parents: 27954
diff changeset
2279 bw!
38332c6da029 patch 8.2.4710: smart indenting does not work after completion
Bram Moolenaar <Bram@vim.org>
parents: 27954
diff changeset
2280 delfunction! FooBarComplete
38332c6da029 patch 8.2.4710: smart indenting does not work after completion
Bram Moolenaar <Bram@vim.org>
parents: 27954
diff changeset
2281 endfunc
38332c6da029 patch 8.2.4710: smart indenting does not work after completion
Bram Moolenaar <Bram@vim.org>
parents: 27954
diff changeset
2282
29355
796198629190 patch 9.0.0020: with some completion reading past end of string
Bram Moolenaar <Bram@vim.org>
parents: 29014
diff changeset
2283 func Test_complete_overrun()
796198629190 patch 9.0.0020: with some completion reading past end of string
Bram Moolenaar <Bram@vim.org>
parents: 29014
diff changeset
2284 " this was going past the end of the copied text
796198629190 patch 9.0.0020: with some completion reading past end of string
Bram Moolenaar <Bram@vim.org>
parents: 29014
diff changeset
2285 new
796198629190 patch 9.0.0020: with some completion reading past end of string
Bram Moolenaar <Bram@vim.org>
parents: 29014
diff changeset
2286 sil norm si”0s0 
796198629190 patch 9.0.0020: with some completion reading past end of string
Bram Moolenaar <Bram@vim.org>
parents: 29014
diff changeset
2287 bwipe!
796198629190 patch 9.0.0020: with some completion reading past end of string
Bram Moolenaar <Bram@vim.org>
parents: 29014
diff changeset
2288 endfunc
796198629190 patch 9.0.0020: with some completion reading past end of string
Bram Moolenaar <Bram@vim.org>
parents: 29014
diff changeset
2289
29406
979ce206409a patch 9.0.0045: reading past end of completion with a long line
Bram Moolenaar <Bram@vim.org>
parents: 29369
diff changeset
2290 func Test_infercase_very_long_line()
979ce206409a patch 9.0.0045: reading past end of completion with a long line
Bram Moolenaar <Bram@vim.org>
parents: 29369
diff changeset
2291 " this was truncating the line when inferring case
979ce206409a patch 9.0.0045: reading past end of completion with a long line
Bram Moolenaar <Bram@vim.org>
parents: 29369
diff changeset
2292 new
979ce206409a patch 9.0.0045: reading past end of completion with a long line
Bram Moolenaar <Bram@vim.org>
parents: 29369
diff changeset
2293 let longLine = "blah "->repeat(300)
979ce206409a patch 9.0.0045: reading past end of completion with a long line
Bram Moolenaar <Bram@vim.org>
parents: 29369
diff changeset
2294 let verylongLine = "blah "->repeat(400)
979ce206409a patch 9.0.0045: reading past end of completion with a long line
Bram Moolenaar <Bram@vim.org>
parents: 29369
diff changeset
2295 call setline(1, verylongLine)
979ce206409a patch 9.0.0045: reading past end of completion with a long line
Bram Moolenaar <Bram@vim.org>
parents: 29369
diff changeset
2296 call setline(2, longLine)
979ce206409a patch 9.0.0045: reading past end of completion with a long line
Bram Moolenaar <Bram@vim.org>
parents: 29369
diff changeset
2297 set ic infercase
979ce206409a patch 9.0.0045: reading past end of completion with a long line
Bram Moolenaar <Bram@vim.org>
parents: 29369
diff changeset
2298 exe "normal 2Go\<C-X>\<C-L>\<Esc>"
979ce206409a patch 9.0.0045: reading past end of completion with a long line
Bram Moolenaar <Bram@vim.org>
parents: 29369
diff changeset
2299 call assert_equal(longLine, getline(3))
979ce206409a patch 9.0.0045: reading past end of completion with a long line
Bram Moolenaar <Bram@vim.org>
parents: 29369
diff changeset
2300
29436
6888567953ca patch 9.0.0060: accessing uninitialized memory when completing long line
Bram Moolenaar <Bram@vim.org>
parents: 29408
diff changeset
2301 " check that the too long text is NUL terminated
6888567953ca patch 9.0.0060: accessing uninitialized memory when completing long line
Bram Moolenaar <Bram@vim.org>
parents: 29408
diff changeset
2302 %del
6888567953ca patch 9.0.0060: accessing uninitialized memory when completing long line
Bram Moolenaar <Bram@vim.org>
parents: 29408
diff changeset
2303 norm o
6888567953ca patch 9.0.0060: accessing uninitialized memory when completing long line
Bram Moolenaar <Bram@vim.org>
parents: 29408
diff changeset
2304 norm 1987ax
6888567953ca patch 9.0.0060: accessing uninitialized memory when completing long line
Bram Moolenaar <Bram@vim.org>
parents: 29408
diff changeset
2305 exec "norm ox\<C-X>\<C-L>"
6888567953ca patch 9.0.0060: accessing uninitialized memory when completing long line
Bram Moolenaar <Bram@vim.org>
parents: 29408
diff changeset
2306 call assert_equal(repeat('x', 1987), getline(3))
6888567953ca patch 9.0.0060: accessing uninitialized memory when completing long line
Bram Moolenaar <Bram@vim.org>
parents: 29408
diff changeset
2307
29406
979ce206409a patch 9.0.0045: reading past end of completion with a long line
Bram Moolenaar <Bram@vim.org>
parents: 29369
diff changeset
2308 bwipe!
979ce206409a patch 9.0.0045: reading past end of completion with a long line
Bram Moolenaar <Bram@vim.org>
parents: 29369
diff changeset
2309 set noic noinfercase
979ce206409a patch 9.0.0045: reading past end of completion with a long line
Bram Moolenaar <Bram@vim.org>
parents: 29369
diff changeset
2310 endfunc
979ce206409a patch 9.0.0045: reading past end of completion with a long line
Bram Moolenaar <Bram@vim.org>
parents: 29369
diff changeset
2311
29408
c12fb2c5b1b3 patch 9.0.0046: reading past end of completion with duplicate match
Bram Moolenaar <Bram@vim.org>
parents: 29406
diff changeset
2312 func Test_ins_complete_add()
c12fb2c5b1b3 patch 9.0.0046: reading past end of completion with duplicate match
Bram Moolenaar <Bram@vim.org>
parents: 29406
diff changeset
2313 " this was reading past the end of allocated memory
c12fb2c5b1b3 patch 9.0.0046: reading past end of completion with duplicate match
Bram Moolenaar <Bram@vim.org>
parents: 29406
diff changeset
2314 new
c12fb2c5b1b3 patch 9.0.0046: reading past end of completion with duplicate match
Bram Moolenaar <Bram@vim.org>
parents: 29406
diff changeset
2315 norm o
c12fb2c5b1b3 patch 9.0.0046: reading past end of completion with duplicate match
Bram Moolenaar <Bram@vim.org>
parents: 29406
diff changeset
2316 norm 7o€€
c12fb2c5b1b3 patch 9.0.0046: reading past end of completion with duplicate match
Bram Moolenaar <Bram@vim.org>
parents: 29406
diff changeset
2317 sil! norm o
c12fb2c5b1b3 patch 9.0.0046: reading past end of completion with duplicate match
Bram Moolenaar <Bram@vim.org>
parents: 29406
diff changeset
2318
c12fb2c5b1b3 patch 9.0.0046: reading past end of completion with duplicate match
Bram Moolenaar <Bram@vim.org>
parents: 29406
diff changeset
2319 bwipe!
c12fb2c5b1b3 patch 9.0.0046: reading past end of completion with duplicate match
Bram Moolenaar <Bram@vim.org>
parents: 29406
diff changeset
2320 endfunc
c12fb2c5b1b3 patch 9.0.0046: reading past end of completion with duplicate match
Bram Moolenaar <Bram@vim.org>
parents: 29406
diff changeset
2321
29521
f538704ca03b patch 9.0.0102: reading past end of line with insert mode completion
Bram Moolenaar <Bram@vim.org>
parents: 29501
diff changeset
2322 func Test_ins_complete_end_of_line()
f538704ca03b patch 9.0.0102: reading past end of line with insert mode completion
Bram Moolenaar <Bram@vim.org>
parents: 29501
diff changeset
2323 " this was reading past the end of the line
31849
dbec60b8c253 patch 9.0.1257: code style is not check in test scripts
Bram Moolenaar <Bram@vim.org>
parents: 31459
diff changeset
2324 new
29521
f538704ca03b patch 9.0.0102: reading past end of line with insert mode completion
Bram Moolenaar <Bram@vim.org>
parents: 29501
diff changeset
2325 norm 8o€ý 
f538704ca03b patch 9.0.0102: reading past end of line with insert mode completion
Bram Moolenaar <Bram@vim.org>
parents: 29501
diff changeset
2326 sil! norm o
f538704ca03b patch 9.0.0102: reading past end of line with insert mode completion
Bram Moolenaar <Bram@vim.org>
parents: 29501
diff changeset
2327
f538704ca03b patch 9.0.0102: reading past end of line with insert mode completion
Bram Moolenaar <Bram@vim.org>
parents: 29501
diff changeset
2328 bwipe!
f538704ca03b patch 9.0.0102: reading past end of line with insert mode completion
Bram Moolenaar <Bram@vim.org>
parents: 29501
diff changeset
2329 endfunc
29406
979ce206409a patch 9.0.0045: reading past end of completion with a long line
Bram Moolenaar <Bram@vim.org>
parents: 29369
diff changeset
2330
30487
79e2d9b7780c patch 9.0.0579: using freed memory when 'tagfunc' wipes out buffer
Bram Moolenaar <Bram@vim.org>
parents: 30473
diff changeset
2331 func s:Tagfunc(t,f,o)
79e2d9b7780c patch 9.0.0579: using freed memory when 'tagfunc' wipes out buffer
Bram Moolenaar <Bram@vim.org>
parents: 30473
diff changeset
2332 bwipe!
79e2d9b7780c patch 9.0.0579: using freed memory when 'tagfunc' wipes out buffer
Bram Moolenaar <Bram@vim.org>
parents: 30473
diff changeset
2333 return []
79e2d9b7780c patch 9.0.0579: using freed memory when 'tagfunc' wipes out buffer
Bram Moolenaar <Bram@vim.org>
parents: 30473
diff changeset
2334 endfunc
79e2d9b7780c patch 9.0.0579: using freed memory when 'tagfunc' wipes out buffer
Bram Moolenaar <Bram@vim.org>
parents: 30473
diff changeset
2335
79e2d9b7780c patch 9.0.0579: using freed memory when 'tagfunc' wipes out buffer
Bram Moolenaar <Bram@vim.org>
parents: 30473
diff changeset
2336 " This was using freed memory, since 'complete' was in a wiped out buffer.
79e2d9b7780c patch 9.0.0579: using freed memory when 'tagfunc' wipes out buffer
Bram Moolenaar <Bram@vim.org>
parents: 30473
diff changeset
2337 " Also using a window that was closed.
79e2d9b7780c patch 9.0.0579: using freed memory when 'tagfunc' wipes out buffer
Bram Moolenaar <Bram@vim.org>
parents: 30473
diff changeset
2338 func Test_tagfunc_wipes_out_buffer()
79e2d9b7780c patch 9.0.0579: using freed memory when 'tagfunc' wipes out buffer
Bram Moolenaar <Bram@vim.org>
parents: 30473
diff changeset
2339 new
79e2d9b7780c patch 9.0.0579: using freed memory when 'tagfunc' wipes out buffer
Bram Moolenaar <Bram@vim.org>
parents: 30473
diff changeset
2340 set complete=.,t,w,b,u,i
79e2d9b7780c patch 9.0.0579: using freed memory when 'tagfunc' wipes out buffer
Bram Moolenaar <Bram@vim.org>
parents: 30473
diff changeset
2341 se tagfunc=s:Tagfunc
79e2d9b7780c patch 9.0.0579: using freed memory when 'tagfunc' wipes out buffer
Bram Moolenaar <Bram@vim.org>
parents: 30473
diff changeset
2342 sil norm i
79e2d9b7780c patch 9.0.0579: using freed memory when 'tagfunc' wipes out buffer
Bram Moolenaar <Bram@vim.org>
parents: 30473
diff changeset
2343
79e2d9b7780c patch 9.0.0579: using freed memory when 'tagfunc' wipes out buffer
Bram Moolenaar <Bram@vim.org>
parents: 30473
diff changeset
2344 bwipe!
79e2d9b7780c patch 9.0.0579: using freed memory when 'tagfunc' wipes out buffer
Bram Moolenaar <Bram@vim.org>
parents: 30473
diff changeset
2345 endfunc
79e2d9b7780c patch 9.0.0579: using freed memory when 'tagfunc' wipes out buffer
Bram Moolenaar <Bram@vim.org>
parents: 30473
diff changeset
2346
32202
eae369cd4dcf patch 9.0.1432: completion popup in wrong position with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents: 32080
diff changeset
2347 func Test_ins_complete_popup_position()
eae369cd4dcf patch 9.0.1432: completion popup in wrong position with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents: 32080
diff changeset
2348 CheckScreendump
eae369cd4dcf patch 9.0.1432: completion popup in wrong position with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents: 32080
diff changeset
2349
eae369cd4dcf patch 9.0.1432: completion popup in wrong position with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents: 32080
diff changeset
2350 let lines =<< trim END
eae369cd4dcf patch 9.0.1432: completion popup in wrong position with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents: 32080
diff changeset
2351 vim9script
eae369cd4dcf patch 9.0.1432: completion popup in wrong position with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents: 32080
diff changeset
2352 set nowrap
eae369cd4dcf patch 9.0.1432: completion popup in wrong position with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents: 32080
diff changeset
2353 setline(1, ['one', 'two', 'this is line ', 'four'])
eae369cd4dcf patch 9.0.1432: completion popup in wrong position with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents: 32080
diff changeset
2354 prop_type_add('test', {highlight: 'Error'})
eae369cd4dcf patch 9.0.1432: completion popup in wrong position with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents: 32080
diff changeset
2355 prop_add(3, 0, {
eae369cd4dcf patch 9.0.1432: completion popup in wrong position with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents: 32080
diff changeset
2356 text_align: 'above',
eae369cd4dcf patch 9.0.1432: completion popup in wrong position with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents: 32080
diff changeset
2357 text: 'The quick brown fox jumps over the lazy dog',
eae369cd4dcf patch 9.0.1432: completion popup in wrong position with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents: 32080
diff changeset
2358 type: 'test'
eae369cd4dcf patch 9.0.1432: completion popup in wrong position with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents: 32080
diff changeset
2359 })
eae369cd4dcf patch 9.0.1432: completion popup in wrong position with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents: 32080
diff changeset
2360 END
eae369cd4dcf patch 9.0.1432: completion popup in wrong position with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents: 32080
diff changeset
2361 call writefile(lines, 'XinsPopup', 'D')
eae369cd4dcf patch 9.0.1432: completion popup in wrong position with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents: 32080
diff changeset
2362 let buf = RunVimInTerminal('-S XinsPopup', #{rows: 10})
eae369cd4dcf patch 9.0.1432: completion popup in wrong position with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents: 32080
diff changeset
2363
eae369cd4dcf patch 9.0.1432: completion popup in wrong position with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents: 32080
diff changeset
2364 call term_sendkeys(buf, "3GA\<C-N>")
eae369cd4dcf patch 9.0.1432: completion popup in wrong position with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents: 32080
diff changeset
2365 call VerifyScreenDump(buf, 'Test_ins_complete_popup_position_1', {})
eae369cd4dcf patch 9.0.1432: completion popup in wrong position with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents: 32080
diff changeset
2366
eae369cd4dcf patch 9.0.1432: completion popup in wrong position with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents: 32080
diff changeset
2367 call StopVimInTerminal(buf)
eae369cd4dcf patch 9.0.1432: completion popup in wrong position with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents: 32080
diff changeset
2368 endfunc
eae369cd4dcf patch 9.0.1432: completion popup in wrong position with virtual text "above"
Bram Moolenaar <Bram@vim.org>
parents: 32080
diff changeset
2369
33538
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2370 func GetCompleteInfo()
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2371 let g:compl_info = complete_info()
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2372 return ''
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2373 endfunc
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2374
33589
efe4751b93b1 patch 9.0.2039: completion shows current word after completion restart
Christian Brabandt <cb@256bit.org>
parents: 33538
diff changeset
2375 func Test_completion_restart()
efe4751b93b1 patch 9.0.2039: completion shows current word after completion restart
Christian Brabandt <cb@256bit.org>
parents: 33538
diff changeset
2376 new
efe4751b93b1 patch 9.0.2039: completion shows current word after completion restart
Christian Brabandt <cb@256bit.org>
parents: 33538
diff changeset
2377 set complete=. completeopt=menuone backspace=2
efe4751b93b1 patch 9.0.2039: completion shows current word after completion restart
Christian Brabandt <cb@256bit.org>
parents: 33538
diff changeset
2378 call setline(1, 'workhorse workhorse')
efe4751b93b1 patch 9.0.2039: completion shows current word after completion restart
Christian Brabandt <cb@256bit.org>
parents: 33538
diff changeset
2379 exe "normal $a\<C-N>\<BS>\<BS>\<C-R>=GetCompleteInfo()\<CR>"
efe4751b93b1 patch 9.0.2039: completion shows current word after completion restart
Christian Brabandt <cb@256bit.org>
parents: 33538
diff changeset
2380 call assert_equal(1, len(g:compl_info['items']))
efe4751b93b1 patch 9.0.2039: completion shows current word after completion restart
Christian Brabandt <cb@256bit.org>
parents: 33538
diff changeset
2381 call assert_equal('workhorse', g:compl_info['items'][0]['word'])
efe4751b93b1 patch 9.0.2039: completion shows current word after completion restart
Christian Brabandt <cb@256bit.org>
parents: 33538
diff changeset
2382 set complete& completeopt& backspace&
efe4751b93b1 patch 9.0.2039: completion shows current word after completion restart
Christian Brabandt <cb@256bit.org>
parents: 33538
diff changeset
2383 bwipe!
efe4751b93b1 patch 9.0.2039: completion shows current word after completion restart
Christian Brabandt <cb@256bit.org>
parents: 33538
diff changeset
2384 endfunc
efe4751b93b1 patch 9.0.2039: completion shows current word after completion restart
Christian Brabandt <cb@256bit.org>
parents: 33538
diff changeset
2385
33538
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2386 func Test_complete_info_index()
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2387 new
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2388 call setline(1, ["aaa", "bbb", "ccc", "ddd", "eee", "fff"])
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2389 inoremap <buffer><F5> <C-R>=GetCompleteInfo()<CR>
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2390
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2391 " Ensure 'index' in complete_info() is coherent with the 'items' array.
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2392
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2393 set completeopt=menu,preview
33674
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2394 " Search forward
33538
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2395 call feedkeys("Go\<C-X>\<C-N>\<F5>\<Esc>_dd", 'tx')
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2396 call assert_equal("aaa", g:compl_info['items'][g:compl_info['selected']]['word'])
33674
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2397 call assert_equal(6 , len(g:compl_info['items']))
33538
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2398 call feedkeys("Go\<C-X>\<C-N>\<C-N>\<F5>\<Esc>_dd", 'tx')
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2399 call assert_equal("bbb", g:compl_info['items'][g:compl_info['selected']]['word'])
33674
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2400 call assert_equal(6 , len(g:compl_info['items']))
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2401 call feedkeys("Go\<C-X>\<C-N>\<C-N>\<C-N>\<F5>\<Esc>_dd", 'tx')
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2402 call assert_equal("ccc", g:compl_info['items'][g:compl_info['selected']]['word'])
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2403 call assert_equal(6 , len(g:compl_info['items']))
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2404 call feedkeys("Go\<C-X>\<C-N>\<C-N>\<C-N>\<C-N>\<F5>\<Esc>_dd", 'tx')
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2405 call assert_equal("ddd", g:compl_info['items'][g:compl_info['selected']]['word'])
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2406 call assert_equal(6 , len(g:compl_info['items']))
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2407 call feedkeys("Go\<C-X>\<C-N>\<C-N>\<C-N>\<C-N>\<C-N>\<F5>\<Esc>_dd", 'tx')
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2408 call assert_equal("eee", g:compl_info['items'][g:compl_info['selected']]['word'])
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2409 call assert_equal(6 , len(g:compl_info['items']))
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2410 call feedkeys("Go\<C-X>\<C-N>\<C-N>\<C-N>\<C-N>\<C-N>\<C-N>\<F5>\<Esc>_dd", 'tx')
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2411 call assert_equal("fff", g:compl_info['items'][g:compl_info['selected']]['word'])
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2412 call assert_equal(6 , len(g:compl_info['items']))
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2413 " Search forward: unselected item
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2414 call feedkeys("Go\<C-X>\<C-N>\<C-N>\<C-N>\<C-N>\<C-N>\<C-N>\<C-N>\<F5>\<Esc>_dd", 'tx')
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2415 call assert_equal(6 , len(g:compl_info['items']))
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2416 call assert_equal(-1 , g:compl_info['selected'])
33538
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2417
33674
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2418 " Search backward
33538
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2419 call feedkeys("Go\<C-X>\<C-P>\<F5>\<Esc>_dd", 'tx')
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2420 call assert_equal("fff", g:compl_info['items'][g:compl_info['selected']]['word'])
33674
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2421 call assert_equal(6 , len(g:compl_info['items']))
33538
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2422 call feedkeys("Go\<C-X>\<C-P>\<C-P>\<F5>\<Esc>_dd", 'tx')
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2423 call assert_equal("eee", g:compl_info['items'][g:compl_info['selected']]['word'])
33674
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2424 call assert_equal(6 , len(g:compl_info['items']))
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2425 call feedkeys("Go\<C-X>\<C-P>\<C-P>\<C-P>\<F5>\<Esc>_dd", 'tx')
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2426 call assert_equal("ddd", g:compl_info['items'][g:compl_info['selected']]['word'])
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2427 call assert_equal(6 , len(g:compl_info['items']))
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2428 call feedkeys("Go\<C-X>\<C-P>\<C-P>\<C-P>\<C-P>\<F5>\<Esc>_dd", 'tx')
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2429 call assert_equal("ccc", g:compl_info['items'][g:compl_info['selected']]['word'])
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2430 call assert_equal(6 , len(g:compl_info['items']))
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2431 call feedkeys("Go\<C-X>\<C-P>\<C-P>\<C-P>\<C-P>\<C-P>\<F5>\<Esc>_dd", 'tx')
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2432 call assert_equal("bbb", g:compl_info['items'][g:compl_info['selected']]['word'])
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2433 call assert_equal(6 , len(g:compl_info['items']))
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2434 call feedkeys("Go\<C-X>\<C-P>\<C-P>\<C-P>\<C-P>\<C-P>\<C-P>\<F5>\<Esc>_dd", 'tx')
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2435 call assert_equal("aaa", g:compl_info['items'][g:compl_info['selected']]['word'])
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2436 call assert_equal(6 , len(g:compl_info['items']))
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2437 " search backwards: unselected item
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2438 call feedkeys("Go\<C-X>\<C-P>\<C-P>\<C-P>\<C-P>\<C-P>\<C-P>\<C-P>\<F5>\<Esc>_dd", 'tx')
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2439 call assert_equal(6 , len(g:compl_info['items']))
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2440 call assert_equal(-1 , g:compl_info['selected'])
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2441
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2442 " switch direction: forwards, then backwards
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2443 call feedkeys("Go\<C-X>\<C-N>\<C-P>\<C-P>\<F5>\<Esc>_dd", 'tx')
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2444 call assert_equal("fff", g:compl_info['items'][g:compl_info['selected']]['word'])
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2445 call assert_equal(6 , len(g:compl_info['items']))
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2446 " switch direction: forwards, then backwards, then forwards again
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2447 call feedkeys("Go\<C-X>\<C-N>\<C-P>\<C-P>\<F5>\<Esc>_dd", 'tx')
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2448 call feedkeys("Go\<C-X>\<C-N>\<C-N>\<C-P>\<C-P>\<C-N>\<F5>\<Esc>_dd", 'tx')
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2449 call assert_equal("aaa", g:compl_info['items'][g:compl_info['selected']]['word'])
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2450 call assert_equal(6 , len(g:compl_info['items']))
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2451
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2452 " switch direction: backwards, then forwards
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2453 call feedkeys("Go\<C-X>\<C-P>\<C-N>\<C-N>\<F5>\<Esc>_dd", 'tx')
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2454 call assert_equal("aaa", g:compl_info['items'][g:compl_info['selected']]['word'])
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2455 call assert_equal(6 , len(g:compl_info['items']))
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2456 " switch direction: backwards, then forwards, then backwards again
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2457 call feedkeys("Go\<C-X>\<C-P>\<C-P>\<C-N>\<C-N>\<C-P>\<F5>\<Esc>_dd", 'tx')
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2458 call assert_equal("fff", g:compl_info['items'][g:compl_info['selected']]['word'])
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2459 call assert_equal(6 , len(g:compl_info['items']))
33538
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2460
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2461 " Add 'noselect', check that 'selected' is -1 when nothing is selected.
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2462 set completeopt+=noselect
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2463 " Search forward.
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2464 call feedkeys("Go\<C-X>\<C-N>\<F5>\<Esc>_dd", 'tx')
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2465 call assert_equal(-1, g:compl_info['selected'])
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2466
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2467 " Search backward.
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2468 call feedkeys("Go\<C-X>\<C-P>\<F5>\<Esc>_dd", 'tx')
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2469 call assert_equal(-1, g:compl_info['selected'])
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2470
33674
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2471 call feedkeys("Go\<C-X>\<C-N>\<C-P>\<F5>\<Esc>_dd", 'tx')
34596
5a8340e044f4 patch 9.1.0190: complete_info() returns wrong order of items
Christian Brabandt <cb@256bit.org>
parents: 34240
diff changeset
2472 call assert_equal(5, g:compl_info['selected'])
33674
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2473 call assert_equal(6 , len(g:compl_info['items']))
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2474 call assert_equal("fff", g:compl_info['items'][g:compl_info['selected']]['word'])
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2475 call feedkeys("Go\<C-X>\<C-N>\<C-N>\<C-N>\<C-N>\<C-N>\<C-N>\<C-N>\<C-N>\<C-N>\<F5>\<Esc>_dd", 'tx')
33680
76ff7b7b44f2 patch 9.0.2077: CI fails because of trailing whitespace in test
Christian Brabandt <cb@256bit.org>
parents: 33674
diff changeset
2476 call assert_equal("aaa", g:compl_info['items'][g:compl_info['selected']]['word'])
33674
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2477 call assert_equal(6 , len(g:compl_info['items']))
33713
9aa03e12b2b5 patch 9.0.2090: complete_info() skips entries with 'noselect'
Christian Brabandt <cb@256bit.org>
parents: 33680
diff changeset
2478 call feedkeys("Go\<C-X>\<C-N>\<F5>\<Esc>_dd", 'tx')
9aa03e12b2b5 patch 9.0.2090: complete_info() skips entries with 'noselect'
Christian Brabandt <cb@256bit.org>
parents: 33680
diff changeset
2479 call assert_equal(-1, g:compl_info['selected'])
9aa03e12b2b5 patch 9.0.2090: complete_info() skips entries with 'noselect'
Christian Brabandt <cb@256bit.org>
parents: 33680
diff changeset
2480 call assert_equal(6 , len(g:compl_info['items']))
33674
021e5bb88513 patch 9.0.2074: Completion menu may be wrong
Christian Brabandt <cb@256bit.org>
parents: 33589
diff changeset
2481
33538
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2482 set completeopt&
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2483 bwipe!
59879206a13d patch 9.0.2018: complete_info() returns wrong index
Christian Brabandt <cb@256bit.org>
parents: 32202
diff changeset
2484 endfunc
30487
79e2d9b7780c patch 9.0.0579: using freed memory when 'tagfunc' wipes out buffer
Bram Moolenaar <Bram@vim.org>
parents: 30473
diff changeset
2485
34240
ac9356547a7b patch 9.1.0065: Segfault with CompleteChanged autocommand
Christian Brabandt <cb@256bit.org>
parents: 33713
diff changeset
2486 func Test_complete_changed_complete_info()
ac9356547a7b patch 9.1.0065: Segfault with CompleteChanged autocommand
Christian Brabandt <cb@256bit.org>
parents: 33713
diff changeset
2487 CheckRunVimInTerminal
ac9356547a7b patch 9.1.0065: Segfault with CompleteChanged autocommand
Christian Brabandt <cb@256bit.org>
parents: 33713
diff changeset
2488 " this used to crash vim, see #13929
ac9356547a7b patch 9.1.0065: Segfault with CompleteChanged autocommand
Christian Brabandt <cb@256bit.org>
parents: 33713
diff changeset
2489 let lines =<< trim END
ac9356547a7b patch 9.1.0065: Segfault with CompleteChanged autocommand
Christian Brabandt <cb@256bit.org>
parents: 33713
diff changeset
2490 set completeopt=menuone
ac9356547a7b patch 9.1.0065: Segfault with CompleteChanged autocommand
Christian Brabandt <cb@256bit.org>
parents: 33713
diff changeset
2491 autocmd CompleteChanged * call complete_info(['items'])
ac9356547a7b patch 9.1.0065: Segfault with CompleteChanged autocommand
Christian Brabandt <cb@256bit.org>
parents: 33713
diff changeset
2492 call feedkeys("iii\<cr>\<c-p>")
ac9356547a7b patch 9.1.0065: Segfault with CompleteChanged autocommand
Christian Brabandt <cb@256bit.org>
parents: 33713
diff changeset
2493 END
ac9356547a7b patch 9.1.0065: Segfault with CompleteChanged autocommand
Christian Brabandt <cb@256bit.org>
parents: 33713
diff changeset
2494 call writefile(lines, 'Xsegfault', 'D')
ac9356547a7b patch 9.1.0065: Segfault with CompleteChanged autocommand
Christian Brabandt <cb@256bit.org>
parents: 33713
diff changeset
2495 let buf = RunVimInTerminal('-S Xsegfault', #{rows: 5})
ac9356547a7b patch 9.1.0065: Segfault with CompleteChanged autocommand
Christian Brabandt <cb@256bit.org>
parents: 33713
diff changeset
2496 call WaitForAssert({-> assert_match('^ii', term_getline(buf, 1))}, 1000)
ac9356547a7b patch 9.1.0065: Segfault with CompleteChanged autocommand
Christian Brabandt <cb@256bit.org>
parents: 33713
diff changeset
2497 call StopVimInTerminal(buf)
ac9356547a7b patch 9.1.0065: Segfault with CompleteChanged autocommand
Christian Brabandt <cb@256bit.org>
parents: 33713
diff changeset
2498 endfunc
ac9356547a7b patch 9.1.0065: Segfault with CompleteChanged autocommand
Christian Brabandt <cb@256bit.org>
parents: 33713
diff changeset
2499
34753
a87c4383404a patch 9.1.0254: [security]: Heap buffer overflow when calling complete_add() in 'cfu'
Christian Brabandt <cb@256bit.org>
parents: 34678
diff changeset
2500 func Test_completefunc_first_call_complete_add()
a87c4383404a patch 9.1.0254: [security]: Heap buffer overflow when calling complete_add() in 'cfu'
Christian Brabandt <cb@256bit.org>
parents: 34678
diff changeset
2501 new
a87c4383404a patch 9.1.0254: [security]: Heap buffer overflow when calling complete_add() in 'cfu'
Christian Brabandt <cb@256bit.org>
parents: 34678
diff changeset
2502
a87c4383404a patch 9.1.0254: [security]: Heap buffer overflow when calling complete_add() in 'cfu'
Christian Brabandt <cb@256bit.org>
parents: 34678
diff changeset
2503 func Complete(findstart, base) abort
a87c4383404a patch 9.1.0254: [security]: Heap buffer overflow when calling complete_add() in 'cfu'
Christian Brabandt <cb@256bit.org>
parents: 34678
diff changeset
2504 if a:findstart
a87c4383404a patch 9.1.0254: [security]: Heap buffer overflow when calling complete_add() in 'cfu'
Christian Brabandt <cb@256bit.org>
parents: 34678
diff changeset
2505 let col = col('.')
a87c4383404a patch 9.1.0254: [security]: Heap buffer overflow when calling complete_add() in 'cfu'
Christian Brabandt <cb@256bit.org>
parents: 34678
diff changeset
2506 call complete_add('#')
a87c4383404a patch 9.1.0254: [security]: Heap buffer overflow when calling complete_add() in 'cfu'
Christian Brabandt <cb@256bit.org>
parents: 34678
diff changeset
2507 return col - 1
a87c4383404a patch 9.1.0254: [security]: Heap buffer overflow when calling complete_add() in 'cfu'
Christian Brabandt <cb@256bit.org>
parents: 34678
diff changeset
2508 else
a87c4383404a patch 9.1.0254: [security]: Heap buffer overflow when calling complete_add() in 'cfu'
Christian Brabandt <cb@256bit.org>
parents: 34678
diff changeset
2509 return []
a87c4383404a patch 9.1.0254: [security]: Heap buffer overflow when calling complete_add() in 'cfu'
Christian Brabandt <cb@256bit.org>
parents: 34678
diff changeset
2510 endif
a87c4383404a patch 9.1.0254: [security]: Heap buffer overflow when calling complete_add() in 'cfu'
Christian Brabandt <cb@256bit.org>
parents: 34678
diff changeset
2511 endfunc
a87c4383404a patch 9.1.0254: [security]: Heap buffer overflow when calling complete_add() in 'cfu'
Christian Brabandt <cb@256bit.org>
parents: 34678
diff changeset
2512
a87c4383404a patch 9.1.0254: [security]: Heap buffer overflow when calling complete_add() in 'cfu'
Christian Brabandt <cb@256bit.org>
parents: 34678
diff changeset
2513 set completeopt=longest completefunc=Complete
a87c4383404a patch 9.1.0254: [security]: Heap buffer overflow when calling complete_add() in 'cfu'
Christian Brabandt <cb@256bit.org>
parents: 34678
diff changeset
2514 " This used to cause heap-buffer-overflow
a87c4383404a patch 9.1.0254: [security]: Heap buffer overflow when calling complete_add() in 'cfu'
Christian Brabandt <cb@256bit.org>
parents: 34678
diff changeset
2515 call assert_fails('call feedkeys("ifoo#\<C-X>\<C-U>", "xt")', 'E840:')
a87c4383404a patch 9.1.0254: [security]: Heap buffer overflow when calling complete_add() in 'cfu'
Christian Brabandt <cb@256bit.org>
parents: 34678
diff changeset
2516
a87c4383404a patch 9.1.0254: [security]: Heap buffer overflow when calling complete_add() in 'cfu'
Christian Brabandt <cb@256bit.org>
parents: 34678
diff changeset
2517 delfunc Complete
a87c4383404a patch 9.1.0254: [security]: Heap buffer overflow when calling complete_add() in 'cfu'
Christian Brabandt <cb@256bit.org>
parents: 34678
diff changeset
2518 set completeopt& completefunc&
a87c4383404a patch 9.1.0254: [security]: Heap buffer overflow when calling complete_add() in 'cfu'
Christian Brabandt <cb@256bit.org>
parents: 34678
diff changeset
2519 bwipe!
a87c4383404a patch 9.1.0254: [security]: Heap buffer overflow when calling complete_add() in 'cfu'
Christian Brabandt <cb@256bit.org>
parents: 34678
diff changeset
2520 endfunc
a87c4383404a patch 9.1.0254: [security]: Heap buffer overflow when calling complete_add() in 'cfu'
Christian Brabandt <cb@256bit.org>
parents: 34678
diff changeset
2521
35322
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2522 func Test_complete_fuzzy_match()
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2523 func OnPumChange()
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2524 let g:item = get(v:event, 'completed_item', {})
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2525 let g:word = get(g:item, 'word', v:null)
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2526 endfunction
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2527
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2528 augroup AAAAA_Group
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2529 au!
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2530 autocmd CompleteChanged * :call OnPumChange()
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2531 augroup END
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2532
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2533 func Omni_test(findstart, base)
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2534 if a:findstart
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2535 return col(".")
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2536 endif
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2537 return [#{word: "foo"}, #{word: "foobar"}, #{word: "fooBaz"}, #{word: "foobala"}]
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2538 endfunc
35335
193e19c464cc patch 9.1.0467: typos in some comments
Christian Brabandt <cb@256bit.org>
parents: 35322
diff changeset
2539
35322
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2540 new
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2541 set omnifunc=Omni_test
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2542 set completeopt+=noinsert,fuzzy
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2543 call feedkeys("Gi\<C-x>\<C-o>", 'tx')
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2544 call assert_equal('foo', g:word)
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2545 call feedkeys("S\<C-x>\<C-o>fb", 'tx')
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2546 call assert_equal('fooBaz', g:word)
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2547 call feedkeys("S\<C-x>\<C-o>fa", 'tx')
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2548 call assert_equal('foobar', g:word)
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2549 " select next
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2550 call feedkeys("S\<C-x>\<C-o>fb\<C-n>", 'tx')
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2551 call assert_equal('foobar', g:word)
35335
193e19c464cc patch 9.1.0467: typos in some comments
Christian Brabandt <cb@256bit.org>
parents: 35322
diff changeset
2552 " can cyclically select next
35322
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2553 call feedkeys("S\<C-x>\<C-o>fb\<C-n>\<C-n>\<C-n>", 'tx')
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2554 call assert_equal(v:null, g:word)
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2555 " select prev
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2556 call feedkeys("S\<C-x>\<C-o>fb\<C-p>", 'tx')
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2557 call assert_equal(v:null, g:word)
35335
193e19c464cc patch 9.1.0467: typos in some comments
Christian Brabandt <cb@256bit.org>
parents: 35322
diff changeset
2558 " can cyclically select prev
35322
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2559 call feedkeys("S\<C-x>\<C-o>fb\<C-p>\<C-p>\<C-p>\<C-p>", 'tx')
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2560 call assert_equal('fooBaz', g:word)
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2561
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2562 " respect noselect
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2563 set completeopt+=noselect
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2564 call feedkeys("S\<C-x>\<C-o>fb", 'tx')
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2565 call assert_equal(v:null, g:word)
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2566 call feedkeys("S\<C-x>\<C-o>fb\<C-n>", 'tx')
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2567 call assert_equal('fooBaz', g:word)
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2568
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2569 " clean up
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2570 set omnifunc=
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2571 bw!
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2572 set complete& completeopt&
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2573 autocmd! AAAAA_Group
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2574 augroup! AAAAA_Group
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2575 delfunc OnPumChange
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2576 delfunc Omni_test
35335
193e19c464cc patch 9.1.0467: typos in some comments
Christian Brabandt <cb@256bit.org>
parents: 35322
diff changeset
2577 unlet g:item
193e19c464cc patch 9.1.0467: typos in some comments
Christian Brabandt <cb@256bit.org>
parents: 35322
diff changeset
2578 unlet g:word
35322
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2579 endfunc
f0aeb83d01b5 patch 9.1.0463: no fuzzy-matching support for insert-completion
Christian Brabandt <cb@256bit.org>
parents: 35281
diff changeset
2580
35405
9a52a7b13fc5 patch 9.1.0484: Sorting of completeopt+=fuzzy is not stable
Christian Brabandt <cb@256bit.org>
parents: 35340
diff changeset
2581 " Check that tie breaking is stable for completeopt+=fuzzy (which should
9a52a7b13fc5 patch 9.1.0484: Sorting of completeopt+=fuzzy is not stable
Christian Brabandt <cb@256bit.org>
parents: 35340
diff changeset
2582 " behave the same on different platforms).
9a52a7b13fc5 patch 9.1.0484: Sorting of completeopt+=fuzzy is not stable
Christian Brabandt <cb@256bit.org>
parents: 35340
diff changeset
2583 func Test_complete_fuzzy_match_tie()
9a52a7b13fc5 patch 9.1.0484: Sorting of completeopt+=fuzzy is not stable
Christian Brabandt <cb@256bit.org>
parents: 35340
diff changeset
2584 new
9a52a7b13fc5 patch 9.1.0484: Sorting of completeopt+=fuzzy is not stable
Christian Brabandt <cb@256bit.org>
parents: 35340
diff changeset
2585 set completeopt+=fuzzy,noselect
9a52a7b13fc5 patch 9.1.0484: Sorting of completeopt+=fuzzy is not stable
Christian Brabandt <cb@256bit.org>
parents: 35340
diff changeset
2586 call setline(1, ['aaabbccc', 'aaabbCCC', 'aaabbcccc', 'aaabbCCCC', ''])
9a52a7b13fc5 patch 9.1.0484: Sorting of completeopt+=fuzzy is not stable
Christian Brabandt <cb@256bit.org>
parents: 35340
diff changeset
2587
9a52a7b13fc5 patch 9.1.0484: Sorting of completeopt+=fuzzy is not stable
Christian Brabandt <cb@256bit.org>
parents: 35340
diff changeset
2588 call feedkeys("Gcc\<C-X>\<C-N>ab\<C-N>\<C-Y>", 'tx')
9a52a7b13fc5 patch 9.1.0484: Sorting of completeopt+=fuzzy is not stable
Christian Brabandt <cb@256bit.org>
parents: 35340
diff changeset
2589 call assert_equal('aaabbccc', getline('.'))
9a52a7b13fc5 patch 9.1.0484: Sorting of completeopt+=fuzzy is not stable
Christian Brabandt <cb@256bit.org>
parents: 35340
diff changeset
2590 call feedkeys("Gcc\<C-X>\<C-N>ab\<C-N>\<C-N>\<C-Y>", 'tx')
9a52a7b13fc5 patch 9.1.0484: Sorting of completeopt+=fuzzy is not stable
Christian Brabandt <cb@256bit.org>
parents: 35340
diff changeset
2591 call assert_equal('aaabbCCC', getline('.'))
9a52a7b13fc5 patch 9.1.0484: Sorting of completeopt+=fuzzy is not stable
Christian Brabandt <cb@256bit.org>
parents: 35340
diff changeset
2592 call feedkeys("Gcc\<C-X>\<C-N>ab\<C-N>\<C-N>\<C-N>\<C-Y>", 'tx')
9a52a7b13fc5 patch 9.1.0484: Sorting of completeopt+=fuzzy is not stable
Christian Brabandt <cb@256bit.org>
parents: 35340
diff changeset
2593 call assert_equal('aaabbcccc', getline('.'))
9a52a7b13fc5 patch 9.1.0484: Sorting of completeopt+=fuzzy is not stable
Christian Brabandt <cb@256bit.org>
parents: 35340
diff changeset
2594 call feedkeys("Gcc\<C-X>\<C-N>ab\<C-N>\<C-N>\<C-N>\<C-N>\<C-Y>", 'tx')
9a52a7b13fc5 patch 9.1.0484: Sorting of completeopt+=fuzzy is not stable
Christian Brabandt <cb@256bit.org>
parents: 35340
diff changeset
2595 call assert_equal('aaabbCCCC', getline('.'))
9a52a7b13fc5 patch 9.1.0484: Sorting of completeopt+=fuzzy is not stable
Christian Brabandt <cb@256bit.org>
parents: 35340
diff changeset
2596
9a52a7b13fc5 patch 9.1.0484: Sorting of completeopt+=fuzzy is not stable
Christian Brabandt <cb@256bit.org>
parents: 35340
diff changeset
2597 bwipe!
9a52a7b13fc5 patch 9.1.0484: Sorting of completeopt+=fuzzy is not stable
Christian Brabandt <cb@256bit.org>
parents: 35340
diff changeset
2598 set completeopt&
9a52a7b13fc5 patch 9.1.0484: Sorting of completeopt+=fuzzy is not stable
Christian Brabandt <cb@256bit.org>
parents: 35340
diff changeset
2599 endfunc
9a52a7b13fc5 patch 9.1.0484: Sorting of completeopt+=fuzzy is not stable
Christian Brabandt <cb@256bit.org>
parents: 35340
diff changeset
2600
34240
ac9356547a7b patch 9.1.0065: Segfault with CompleteChanged autocommand
Christian Brabandt <cb@256bit.org>
parents: 33713
diff changeset
2601 " vim: shiftwidth=2 sts=2 expandtab nofoldenable