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