blob: bdad26a8c76c3345620800aa9fc2094e613d6251 [file] [log] [blame]
Bram Moolenaar15993ce2017-10-26 20:21:44 +02001
2" Test for insert expansion
3func Test_ins_complete()
Bram Moolenaarcf1ba352017-10-27 00:55:04 +02004 edit test_ins_complete.vim
Bram Moolenaar15993ce2017-10-26 20:21:44 +02005 set ff=unix
6 call writefile(["test11\t36Gepeto\t/Tag/",
7 \ "asd\ttest11file\t36G",
8 \ "Makefile\tto\trun"], 'Xtestfile')
9 call writefile(['', 'start of testfile',
10 \ 'ru',
11 \ 'run1',
12 \ 'run2',
13 \ 'STARTTEST',
14 \ 'ENDTEST',
15 \ 'end of testfile'], 'Xtestdata')
16 set ff&
17
18 enew!
19 edit Xtestdata
20 new
21 call append(0, ['#include "Xtestfile"', ''])
22 call cursor(2, 1)
23
24 set cot=
25 set cpt=.,w
26 " add-expands (word from next line) from other window
27 exe "normal iru\<C-N>\<C-N>\<C-X>\<C-N>\<Esc>\<C-A>"
28 call assert_equal('run1 run3', getline('.'))
29 " add-expands (current buffer first)
30 exe "normal o\<C-P>\<C-X>\<C-N>"
31 call assert_equal('run3 run3', getline('.'))
32 " Local expansion, ends in an empty line (unless it becomes a global
33 " expansion)
34 exe "normal o\<C-X>\<C-P>\<C-P>\<C-P>\<C-P>\<C-P>"
35 call assert_equal('', getline('.'))
36 " starts Local and switches to global add-expansion
37 exe "normal o\<C-X>\<C-P>\<C-P>\<C-X>\<C-X>\<C-N>\<C-X>\<C-N>\<C-N>"
38 call assert_equal('run1 run2', getline('.'))
39
40 set cpt=.,w,i
41 " i-add-expands and switches to local
42 exe "normal OM\<C-N>\<C-X>\<C-N>\<C-X>\<C-N>\<C-X>\<C-X>\<C-X>\<C-P>"
43 call assert_equal("Makefile\tto\trun3", getline('.'))
44 " add-expands lines (it would end in an empty line if it didn't ignored
45 " itself)
46 exe "normal o\<C-X>\<C-L>\<C-X>\<C-L>\<C-P>\<C-P>"
47 call assert_equal("Makefile\tto\trun3", getline('.'))
48 call assert_equal("Makefile\tto\trun3", getline(line('.') - 1))
49
50 set cpt=kXtestfile
51 " checks k-expansion, and file expansion (use Xtest11 instead of test11,
52 " because TEST11.OUT may match first on DOS)
53 write Xtest11.one
54 write Xtest11.two
55 exe "normal o\<C-N>\<Esc>IX\<Esc>A\<C-X>\<C-F>\<C-N>"
56 call assert_equal('Xtest11.two', getline('.'))
57
58 " use CTRL-X CTRL-F to complete Xtest11.one, remove it and then use CTRL-X
59 " CTRL-F again to verify this doesn't cause trouble.
60 exe "normal oXt\<C-X>\<C-F>\<BS>\<BS>\<BS>\<BS>\<BS>\<BS>\<BS>\<BS>\<C-X>\<C-F>"
61 call assert_equal('Xtest11.one', getline('.'))
62 normal ddk
63
64 set cpt=w
65 " checks make_cyclic in other window
66 exe "normal oST\<C-N>\<C-P>\<C-P>\<C-P>\<C-P>"
67 call assert_equal('STARTTEST', getline('.'))
68
69 set cpt=u nohid
70 " checks unloaded buffer expansion
71 only
72 exe "normal oEN\<C-N>"
73 call assert_equal('ENDTEST', getline('.'))
74 " checks adding mode abortion
75 exe "normal ounl\<C-N>\<C-X>\<C-X>\<C-P>"
76 call assert_equal('unless', getline('.'))
77
78 set cpt=t,d def=^\\k* tags=Xtestfile notagbsearch
79 " tag expansion, define add-expansion interrupted
80 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>"
81 call assert_equal('test11file 36Gepeto /Tag/ asd', getline('.'))
82 " t-expansion
83 exe "normal oa\<C-N>\<Esc>"
84 call assert_equal('asd', getline('.'))
85
86 %bw!
87 call delete('Xtestfile')
88 call delete('Xtest11.one')
89 call delete('Xtest11.two')
90 call delete('Xtestdata')
91 set cpt& cot& def& tags& tagbsearch& hidden&
92endfunc