1" Tests for editing the command line. 2 3source check.vim 4source screendump.vim 5source view_util.vim 6source shared.vim 7 8func Test_complete_tab() 9 call writefile(['testfile'], 'Xtestfile') 10 call feedkeys(":e Xtest\t\r", "tx") 11 call assert_equal('testfile', getline(1)) 12 call delete('Xtestfile') 13endfunc 14 15func Test_complete_list() 16 " We can't see the output, but at least we check the code runs properly. 17 call feedkeys(":e test\<C-D>\r", "tx") 18 call assert_equal('test', expand('%:t')) 19 20 " If a command doesn't support completion, then CTRL-D should be literally 21 " used. 22 call feedkeys(":chistory \<C-D>\<C-B>\"\<CR>", 'xt') 23 call assert_equal("\"chistory \<C-D>", @:) 24endfunc 25 26func Test_complete_wildmenu() 27 call mkdir('Xdir1/Xdir2', 'p') 28 call writefile(['testfile1'], 'Xdir1/Xtestfile1') 29 call writefile(['testfile2'], 'Xdir1/Xtestfile2') 30 call writefile(['testfile3'], 'Xdir1/Xdir2/Xtestfile3') 31 call writefile(['testfile3'], 'Xdir1/Xdir2/Xtestfile4') 32 set wildmenu 33 34 " Pressing <Tab> completes, and moves to next files when pressing again. 35 call feedkeys(":e Xdir1/\<Tab>\<Tab>\<CR>", 'tx') 36 call assert_equal('testfile1', getline(1)) 37 call feedkeys(":e Xdir1/\<Tab>\<Tab>\<Tab>\<CR>", 'tx') 38 call assert_equal('testfile2', getline(1)) 39 40 " <S-Tab> is like <Tab> but begin with the last match and then go to 41 " previous. 42 call feedkeys(":e Xdir1/Xtest\<S-Tab>\<CR>", 'tx') 43 call assert_equal('testfile2', getline(1)) 44 call feedkeys(":e Xdir1/Xtest\<S-Tab>\<S-Tab>\<CR>", 'tx') 45 call assert_equal('testfile1', getline(1)) 46 47 " <Left>/<Right> to move to previous/next file. 48 call feedkeys(":e Xdir1/\<Tab>\<Right>\<CR>", 'tx') 49 call assert_equal('testfile1', getline(1)) 50 call feedkeys(":e Xdir1/\<Tab>\<Right>\<Right>\<CR>", 'tx') 51 call assert_equal('testfile2', getline(1)) 52 call feedkeys(":e Xdir1/\<Tab>\<Right>\<Right>\<Left>\<CR>", 'tx') 53 call assert_equal('testfile1', getline(1)) 54 55 " <Up>/<Down> to go up/down directories. 56 call feedkeys(":e Xdir1/\<Tab>\<Down>\<CR>", 'tx') 57 call assert_equal('testfile3', getline(1)) 58 call feedkeys(":e Xdir1/\<Tab>\<Down>\<Up>\<Right>\<CR>", 'tx') 59 call assert_equal('testfile1', getline(1)) 60 61 " Test for canceling the wild menu by adding a character 62 redrawstatus 63 call feedkeys(":e Xdir1/\<Tab>x\<C-B>\"\<CR>", 'xt') 64 call assert_equal('"e Xdir1/Xdir2/x', @:) 65 66 " Completion using a relative path 67 cd Xdir1/Xdir2 68 call feedkeys(":e ../\<Tab>\<Right>\<Down>\<C-A>\<C-B>\"\<CR>", 'tx') 69 call assert_equal('"e Xtestfile3 Xtestfile4', @:) 70 cd - 71 72 cnoremap <expr> <F2> wildmenumode() 73 call feedkeys(":cd Xdir\<Tab>\<F2>\<C-B>\"\<CR>", 'tx') 74 call assert_equal('"cd Xdir1/1', @:) 75 cunmap <F2> 76 77 " cleanup 78 %bwipe 79 call delete('Xdir1/Xdir2/Xtestfile4') 80 call delete('Xdir1/Xdir2/Xtestfile3') 81 call delete('Xdir1/Xtestfile2') 82 call delete('Xdir1/Xtestfile1') 83 call delete('Xdir1/Xdir2', 'd') 84 call delete('Xdir1', 'd') 85 set nowildmenu 86endfunc 87 88func Test_wildmenu_screendump() 89 CheckScreendump 90 91 let lines =<< trim [SCRIPT] 92 set wildmenu hlsearch 93 [SCRIPT] 94 call writefile(lines, 'XTest_wildmenu') 95 96 let buf = RunVimInTerminal('-S XTest_wildmenu', {'rows': 8}) 97 call term_sendkeys(buf, ":vim\<Tab>") 98 call VerifyScreenDump(buf, 'Test_wildmenu_1', {}) 99 100 call term_sendkeys(buf, "\<Tab>") 101 call VerifyScreenDump(buf, 'Test_wildmenu_2', {}) 102 103 call term_sendkeys(buf, "\<Tab>") 104 call VerifyScreenDump(buf, 'Test_wildmenu_3', {}) 105 106 call term_sendkeys(buf, "\<Tab>") 107 call VerifyScreenDump(buf, 'Test_wildmenu_4', {}) 108 call term_sendkeys(buf, "\<Esc>") 109 110 " clean up 111 call StopVimInTerminal(buf) 112 call delete('XTest_wildmenu') 113endfunc 114 115func Test_map_completion() 116 CheckFeature cmdline_compl 117 call feedkeys(":map <unique> <si\<Tab>\<Home>\"\<CR>", 'xt') 118 call assert_equal('"map <unique> <silent>', getreg(':')) 119 call feedkeys(":map <script> <un\<Tab>\<Home>\"\<CR>", 'xt') 120 call assert_equal('"map <script> <unique>', getreg(':')) 121 call feedkeys(":map <expr> <sc\<Tab>\<Home>\"\<CR>", 'xt') 122 call assert_equal('"map <expr> <script>', getreg(':')) 123 call feedkeys(":map <buffer> <e\<Tab>\<Home>\"\<CR>", 'xt') 124 call assert_equal('"map <buffer> <expr>', getreg(':')) 125 call feedkeys(":map <nowait> <b\<Tab>\<Home>\"\<CR>", 'xt') 126 call assert_equal('"map <nowait> <buffer>', getreg(':')) 127 call feedkeys(":map <special> <no\<Tab>\<Home>\"\<CR>", 'xt') 128 call assert_equal('"map <special> <nowait>', getreg(':')) 129 call feedkeys(":map <silent> <sp\<Tab>\<Home>\"\<CR>", 'xt') 130 call assert_equal('"map <silent> <special>', getreg(':')) 131 132 map <Middle>x middle 133 134 map ,f commaf 135 map ,g commaf 136 map <Left> left 137 map <A-Left>x shiftleft 138 call feedkeys(":map ,\<Tab>\<Home>\"\<CR>", 'xt') 139 call assert_equal('"map ,f', getreg(':')) 140 call feedkeys(":map ,\<Tab>\<Tab>\<Home>\"\<CR>", 'xt') 141 call assert_equal('"map ,g', getreg(':')) 142 call feedkeys(":map <L\<Tab>\<Home>\"\<CR>", 'xt') 143 call assert_equal('"map <Left>', getreg(':')) 144 call feedkeys(":map <A-Left>\<Tab>\<Home>\"\<CR>", 'xt') 145 call assert_equal("\"map <A-Left>\<Tab>", getreg(':')) 146 unmap ,f 147 unmap ,g 148 unmap <Left> 149 unmap <A-Left>x 150 151 set cpo-=< cpo-=B cpo-=k 152 map <Left> left 153 call feedkeys(":map <L\<Tab>\<Home>\"\<CR>", 'xt') 154 call assert_equal('"map <Left>', getreg(':')) 155 call feedkeys(":map <M\<Tab>\<Home>\"\<CR>", 'xt') 156 call assert_equal("\"map <M\<Tab>", getreg(':')) 157 unmap <Left> 158 159 set cpo+=< 160 map <Left> left 161 exe "set t_k6=\<Esc>[17~" 162 call feedkeys(":map \<Esc>[17~x f6x\<CR>", 'xt') 163 call feedkeys(":map <L\<Tab>\<Home>\"\<CR>", 'xt') 164 call assert_equal('"map <Left>', getreg(':')) 165 if !has('gui_running') 166 call feedkeys(":map \<Esc>[17~\<Tab>\<Home>\"\<CR>", 'xt') 167 call assert_equal("\"map <F6>x", getreg(':')) 168 endif 169 unmap <Left> 170 call feedkeys(":unmap \<Esc>[17~x\<CR>", 'xt') 171 set cpo-=< 172 173 set cpo+=B 174 map <Left> left 175 call feedkeys(":map <L\<Tab>\<Home>\"\<CR>", 'xt') 176 call assert_equal('"map <Left>', getreg(':')) 177 unmap <Left> 178 set cpo-=B 179 180 set cpo+=k 181 map <Left> left 182 call feedkeys(":map <L\<Tab>\<Home>\"\<CR>", 'xt') 183 call assert_equal('"map <Left>', getreg(':')) 184 unmap <Left> 185 set cpo-=k 186 187 call assert_fails('call feedkeys(":map \\\\%(\<Tab>\<Home>\"\<CR>", "xt")', 'E53:') 188 189 unmap <Middle>x 190 set cpo&vim 191endfunc 192 193func Test_match_completion() 194 CheckFeature cmdline_compl 195 hi Aardig ctermfg=green 196 call feedkeys(":match \<Tab>\<Home>\"\<CR>", 'xt') 197 call assert_equal('"match Aardig', getreg(':')) 198 call feedkeys(":match \<S-Tab>\<Home>\"\<CR>", 'xt') 199 call assert_equal('"match none', getreg(':')) 200endfunc 201 202func Test_highlight_completion() 203 CheckFeature cmdline_compl 204 hi Aardig ctermfg=green 205 call feedkeys(":hi \<Tab>\<Home>\"\<CR>", 'xt') 206 call assert_equal('"hi Aardig', getreg(':')) 207 call feedkeys(":hi default \<Tab>\<Home>\"\<CR>", 'xt') 208 call assert_equal('"hi default Aardig', getreg(':')) 209 call feedkeys(":hi clear Aa\<Tab>\<Home>\"\<CR>", 'xt') 210 call assert_equal('"hi clear Aardig', getreg(':')) 211 call feedkeys(":hi li\<S-Tab>\<Home>\"\<CR>", 'xt') 212 call assert_equal('"hi link', getreg(':')) 213 call feedkeys(":hi d\<S-Tab>\<Home>\"\<CR>", 'xt') 214 call assert_equal('"hi default', getreg(':')) 215 call feedkeys(":hi c\<S-Tab>\<Home>\"\<CR>", 'xt') 216 call assert_equal('"hi clear', getreg(':')) 217 call feedkeys(":hi clear Aardig Aard\<Tab>\<C-B>\"\<CR>", 'xt') 218 call assert_equal('"hi clear Aardig Aardig', getreg(':')) 219 call feedkeys(":hi Aardig \<Tab>\<C-B>\"\<CR>", 'xt') 220 call assert_equal("\"hi Aardig \t", getreg(':')) 221 222 " A cleared group does not show up in completions. 223 hi Anders ctermfg=green 224 call assert_equal(['Aardig', 'Anders'], getcompletion('A', 'highlight')) 225 hi clear Aardig 226 call assert_equal(['Anders'], getcompletion('A', 'highlight')) 227 hi clear Anders 228 call assert_equal([], getcompletion('A', 'highlight')) 229endfunc 230 231" Test for command-line expansion of "hi Ni " (easter egg) 232func Test_highlight_easter_egg() 233 call test_override('ui_delay', 1) 234 call feedkeys(":hi Ni \<Tab>\<C-B>\"\<CR>", 'xt') 235 call assert_equal("\"hi Ni \<Tab>", @:) 236 call test_override('ALL', 0) 237endfunc 238 239func Test_getcompletion() 240 CheckFeature cmdline_compl 241 let groupcount = len(getcompletion('', 'event')) 242 call assert_true(groupcount > 0) 243 let matchcount = len('File'->getcompletion('event')) 244 call assert_true(matchcount > 0) 245 call assert_true(groupcount > matchcount) 246 247 if has('menu') 248 source $VIMRUNTIME/menu.vim 249 let matchcount = len(getcompletion('', 'menu')) 250 call assert_true(matchcount > 0) 251 call assert_equal(['File.'], getcompletion('File', 'menu')) 252 call assert_true(matchcount > 0) 253 let matchcount = len(getcompletion('File.', 'menu')) 254 call assert_true(matchcount > 0) 255 endif 256 257 let l = getcompletion('v:n', 'var') 258 call assert_true(index(l, 'v:null') >= 0) 259 let l = getcompletion('v:notexists', 'var') 260 call assert_equal([], l) 261 262 args a.c b.c 263 let l = getcompletion('', 'arglist') 264 call assert_equal(['a.c', 'b.c'], l) 265 %argdelete 266 267 let l = getcompletion('', 'augroup') 268 call assert_true(index(l, 'END') >= 0) 269 let l = getcompletion('blahblah', 'augroup') 270 call assert_equal([], l) 271 272 let l = getcompletion('', 'behave') 273 call assert_true(index(l, 'mswin') >= 0) 274 let l = getcompletion('not', 'behave') 275 call assert_equal([], l) 276 277 let l = getcompletion('', 'color') 278 call assert_true(index(l, 'default') >= 0) 279 let l = getcompletion('dirty', 'color') 280 call assert_equal([], l) 281 282 let l = getcompletion('', 'command') 283 call assert_true(index(l, 'sleep') >= 0) 284 let l = getcompletion('awake', 'command') 285 call assert_equal([], l) 286 287 let l = getcompletion('', 'dir') 288 call assert_true(index(l, 'samples/') >= 0) 289 let l = getcompletion('NoMatch', 'dir') 290 call assert_equal([], l) 291 292 let l = getcompletion('exe', 'expression') 293 call assert_true(index(l, 'executable(') >= 0) 294 let l = getcompletion('kill', 'expression') 295 call assert_equal([], l) 296 297 let l = getcompletion('tag', 'function') 298 call assert_true(index(l, 'taglist(') >= 0) 299 let l = getcompletion('paint', 'function') 300 call assert_equal([], l) 301 302 let Flambda = {-> 'hello'} 303 let l = getcompletion('', 'function') 304 let l = filter(l, {i, v -> v =~ 'lambda'}) 305 call assert_equal([], l) 306 307 let l = getcompletion('run', 'file') 308 call assert_true(index(l, 'runtest.vim') >= 0) 309 let l = getcompletion('walk', 'file') 310 call assert_equal([], l) 311 set wildignore=*.vim 312 let l = getcompletion('run', 'file', 1) 313 call assert_true(index(l, 'runtest.vim') < 0) 314 set wildignore& 315 316 let l = getcompletion('ha', 'filetype') 317 call assert_true(index(l, 'hamster') >= 0) 318 let l = getcompletion('horse', 'filetype') 319 call assert_equal([], l) 320 321 let l = getcompletion('z', 'syntax') 322 call assert_true(index(l, 'zimbu') >= 0) 323 let l = getcompletion('emacs', 'syntax') 324 call assert_equal([], l) 325 326 let l = getcompletion('jikes', 'compiler') 327 call assert_true(index(l, 'jikes') >= 0) 328 let l = getcompletion('break', 'compiler') 329 call assert_equal([], l) 330 331 let l = getcompletion('last', 'help') 332 call assert_true(index(l, ':tablast') >= 0) 333 let l = getcompletion('giveup', 'help') 334 call assert_equal([], l) 335 336 let l = getcompletion('time', 'option') 337 call assert_true(index(l, 'timeoutlen') >= 0) 338 let l = getcompletion('space', 'option') 339 call assert_equal([], l) 340 341 let l = getcompletion('er', 'highlight') 342 call assert_true(index(l, 'ErrorMsg') >= 0) 343 let l = getcompletion('dark', 'highlight') 344 call assert_equal([], l) 345 346 let l = getcompletion('', 'messages') 347 call assert_true(index(l, 'clear') >= 0) 348 let l = getcompletion('not', 'messages') 349 call assert_equal([], l) 350 351 let l = getcompletion('', 'mapclear') 352 call assert_true(index(l, '<buffer>') >= 0) 353 let l = getcompletion('not', 'mapclear') 354 call assert_equal([], l) 355 356 let l = getcompletion('.', 'shellcmd') 357 call assert_equal(['./', '../'], filter(l, 'v:val =~ "\\./"')) 358 call assert_equal(-1, match(l[2:], '^\.\.\?/$')) 359 let root = has('win32') ? 'C:\\' : '/' 360 let l = getcompletion(root, 'shellcmd') 361 let expected = map(filter(glob(root . '*', 0, 1), 362 \ 'isdirectory(v:val) || executable(v:val)'), 'isdirectory(v:val) ? v:val . ''/'' : v:val') 363 call assert_equal(expected, l) 364 365 if has('cscope') 366 let l = getcompletion('', 'cscope') 367 let cmds = ['add', 'find', 'help', 'kill', 'reset', 'show'] 368 call assert_equal(cmds, l) 369 " using cmdline completion must not change the result 370 call feedkeys(":cscope find \<c-d>\<c-c>", 'xt') 371 let l = getcompletion('', 'cscope') 372 call assert_equal(cmds, l) 373 let keys = ['a', 'c', 'd', 'e', 'f', 'g', 'i', 's', 't'] 374 let l = getcompletion('find ', 'cscope') 375 call assert_equal(keys, l) 376 endif 377 378 if has('signs') 379 sign define Testing linehl=Comment 380 let l = getcompletion('', 'sign') 381 let cmds = ['define', 'jump', 'list', 'place', 'undefine', 'unplace'] 382 call assert_equal(cmds, l) 383 " using cmdline completion must not change the result 384 call feedkeys(":sign list \<c-d>\<c-c>", 'xt') 385 let l = getcompletion('', 'sign') 386 call assert_equal(cmds, l) 387 let l = getcompletion('list ', 'sign') 388 call assert_equal(['Testing'], l) 389 endif 390 391 " Command line completion tests 392 let l = getcompletion('cd ', 'cmdline') 393 call assert_true(index(l, 'samples/') >= 0) 394 let l = getcompletion('cd NoMatch', 'cmdline') 395 call assert_equal([], l) 396 let l = getcompletion('let v:n', 'cmdline') 397 call assert_true(index(l, 'v:null') >= 0) 398 let l = getcompletion('let v:notexists', 'cmdline') 399 call assert_equal([], l) 400 let l = getcompletion('call tag', 'cmdline') 401 call assert_true(index(l, 'taglist(') >= 0) 402 let l = getcompletion('call paint', 'cmdline') 403 call assert_equal([], l) 404 405 " For others test if the name is recognized. 406 let names = ['buffer', 'environment', 'file_in_path', 'mapping', 'tag', 'tag_listfiles', 'user'] 407 if has('cmdline_hist') 408 call add(names, 'history') 409 endif 410 if has('gettext') 411 call add(names, 'locale') 412 endif 413 if has('profile') 414 call add(names, 'syntime') 415 endif 416 417 set tags=Xtags 418 call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", "word\tfile\tcmd"], 'Xtags') 419 420 for name in names 421 let matchcount = len(getcompletion('', name)) 422 call assert_true(matchcount >= 0, 'No matches for ' . name) 423 endfor 424 425 call delete('Xtags') 426 set tags& 427 428 call assert_fails("call getcompletion('\\\\@!\\\\@=', 'buffer')", 'E871:') 429 call assert_fails('call getcompletion("", "burp")', 'E475:') 430 call assert_fails('call getcompletion("abc", [])', 'E475:') 431endfunc 432 433func Test_shellcmd_completion() 434 let save_path = $PATH 435 436 call mkdir('Xpathdir/Xpathsubdir', 'p') 437 call writefile([''], 'Xpathdir/Xfile.exe') 438 call setfperm('Xpathdir/Xfile.exe', 'rwx------') 439 440 " Set PATH to example directory without trailing slash. 441 let $PATH = getcwd() . '/Xpathdir' 442 443 " Test for the ":!<TAB>" case. Previously, this would include subdirs of 444 " dirs in the PATH, even though they won't be executed. We check that only 445 " subdirs of the PWD and executables from the PATH are included in the 446 " suggestions. 447 let actual = getcompletion('X', 'shellcmd') 448 let expected = map(filter(glob('*', 0, 1), 'isdirectory(v:val) && v:val[0] == "X"'), 'v:val . "/"') 449 call insert(expected, 'Xfile.exe') 450 call assert_equal(expected, actual) 451 452 call delete('Xpathdir', 'rf') 453 let $PATH = save_path 454endfunc 455 456func Test_expand_star_star() 457 call mkdir('a/b', 'p') 458 call writefile(['asdfasdf'], 'a/b/fileXname') 459 call feedkeys(":find **/fileXname\<Tab>\<CR>", 'xt') 460 call assert_equal('find a/b/fileXname', getreg(':')) 461 bwipe! 462 call delete('a', 'rf') 463endfunc 464 465func Test_cmdline_paste() 466 let @a = "def" 467 call feedkeys(":abc \<C-R>a ghi\<C-B>\"\<CR>", 'tx') 468 call assert_equal('"abc def ghi', @:) 469 470 new 471 call setline(1, 'asdf.x /tmp/some verylongword a;b-c*d ') 472 473 call feedkeys(":aaa \<C-R>\<C-W> bbb\<C-B>\"\<CR>", 'tx') 474 call assert_equal('"aaa asdf bbb', @:) 475 476 call feedkeys("ft:aaa \<C-R>\<C-F> bbb\<C-B>\"\<CR>", 'tx') 477 call assert_equal('"aaa /tmp/some bbb', @:) 478 479 call feedkeys(":aaa \<C-R>\<C-L> bbb\<C-B>\"\<CR>", 'tx') 480 call assert_equal('"aaa '.getline(1).' bbb', @:) 481 482 set incsearch 483 call feedkeys("fy:aaa veryl\<C-R>\<C-W> bbb\<C-B>\"\<CR>", 'tx') 484 call assert_equal('"aaa verylongword bbb', @:) 485 486 call feedkeys("f;:aaa \<C-R>\<C-A> bbb\<C-B>\"\<CR>", 'tx') 487 call assert_equal('"aaa a;b-c*d bbb', @:) 488 489 call feedkeys(":\<C-\>etoupper(getline(1))\<CR>\<C-B>\"\<CR>", 'tx') 490 call assert_equal('"ASDF.X /TMP/SOME VERYLONGWORD A;B-C*D ', @:) 491 bwipe! 492 493 " Error while typing a command used to cause that it was not executed 494 " in the end. 495 new 496 try 497 call feedkeys(":file \<C-R>%Xtestfile\<CR>", 'tx') 498 catch /^Vim\%((\a\+)\)\=:E32/ 499 " ignore error E32 500 endtry 501 call assert_equal("Xtestfile", bufname("%")) 502 503 " Try to paste an invalid register using <C-R> 504 call feedkeys(":\"one\<C-R>\<C-X>two\<CR>", 'xt') 505 call assert_equal('"onetwo', @:) 506 507 " Test for pasting register containing CTRL-H using CTRL-R and CTRL-R CTRL-R 508 let @a = "xy\<C-H>z" 509 call feedkeys(":\"\<C-R>a\<CR>", 'xt') 510 call assert_equal('"xz', @:) 511 call feedkeys(":\"\<C-R>\<C-R>a\<CR>", 'xt') 512 call assert_equal("\"xy\<C-H>z", @:) 513 call feedkeys(":\"\<C-R>\<C-O>a\<CR>", 'xt') 514 call assert_equal("\"xy\<C-H>z", @:) 515 516 " Test for pasting register containing CTRL-V using CTRL-R and CTRL-R CTRL-R 517 let @a = "xy\<C-V>z" 518 call feedkeys(":\"\<C-R>=@a\<CR>\<cr>", 'xt') 519 call assert_equal('"xyz', @:) 520 call feedkeys(":\"\<C-R>\<C-R>=@a\<CR>\<cr>", 'xt') 521 call assert_equal("\"xy\<C-V>z", @:) 522 523 call assert_beeps('call feedkeys(":\<C-R>=\<C-R>=\<Esc>", "xt")') 524 525 bwipe! 526endfunc 527 528func Test_cmdline_remove_char() 529 let encoding_save = &encoding 530 531 for e in ['utf8', 'latin1'] 532 exe 'set encoding=' . e 533 534 call feedkeys(":abc def\<S-Left>\<Del>\<C-B>\"\<CR>", 'tx') 535 call assert_equal('"abc ef', @:, e) 536 537 call feedkeys(":abc def\<S-Left>\<BS>\<C-B>\"\<CR>", 'tx') 538 call assert_equal('"abcdef', @:) 539 540 call feedkeys(":abc def ghi\<S-Left>\<C-W>\<C-B>\"\<CR>", 'tx') 541 call assert_equal('"abc ghi', @:, e) 542 543 call feedkeys(":abc def\<S-Left>\<C-U>\<C-B>\"\<CR>", 'tx') 544 call assert_equal('"def', @:, e) 545 endfor 546 547 let &encoding = encoding_save 548endfunc 549 550func Test_cmdline_keymap_ctrl_hat() 551 CheckFeature keymap 552 553 set keymap=esperanto 554 call feedkeys(":\"Jxauxdo \<C-^>Jxauxdo \<C-^>Jxauxdo\<CR>", 'tx') 555 call assert_equal('"Jxauxdo Ĵaŭdo Jxauxdo', @:) 556 set keymap= 557endfunc 558 559func Test_illegal_address1() 560 new 561 2;'( 562 2;') 563 quit 564endfunc 565 566func Test_illegal_address2() 567 call writefile(['c', 'x', ' x', '.', '1;y'], 'Xtest.vim') 568 new 569 source Xtest.vim 570 " Trigger calling validate_cursor() 571 diffsp Xtest.vim 572 quit! 573 bwipe! 574 call delete('Xtest.vim') 575endfunc 576 577func Test_cmdline_complete_wildoptions() 578 help 579 call feedkeys(":tag /\<c-a>\<c-b>\"\<cr>", 'tx') 580 let a = join(sort(split(@:)),' ') 581 set wildoptions=tagfile 582 call feedkeys(":tag /\<c-a>\<c-b>\"\<cr>", 'tx') 583 let b = join(sort(split(@:)),' ') 584 call assert_equal(a, b) 585 bw! 586endfunc 587 588func Test_cmdline_complete_user_cmd() 589 command! -complete=color -nargs=1 Foo : 590 call feedkeys(":Foo \<Tab>\<Home>\"\<cr>", 'tx') 591 call assert_equal('"Foo blue', @:) 592 call feedkeys(":Foo b\<Tab>\<Home>\"\<cr>", 'tx') 593 call assert_equal('"Foo blue', @:) 594 delcommand Foo 595endfunc 596 597func s:ScriptLocalFunction() 598 echo 'yes' 599endfunc 600 601func Test_cmdline_complete_user_func() 602 call feedkeys(":func Test_cmdline_complete_user\<Tab>\<Home>\"\<cr>", 'tx') 603 call assert_match('"func Test_cmdline_complete_user', @:) 604 call feedkeys(":func s:ScriptL\<Tab>\<Home>\"\<cr>", 'tx') 605 call assert_match('"func <SNR>\d\+_ScriptLocalFunction', @:) 606endfunc 607 608func Test_cmdline_complete_user_names() 609 if has('unix') && executable('whoami') 610 let whoami = systemlist('whoami')[0] 611 let first_letter = whoami[0] 612 if len(first_letter) > 0 613 " Trying completion of :e ~x where x is the first letter of 614 " the user name should complete to at least the user name. 615 call feedkeys(':e ~' . first_letter . "\<c-a>\<c-B>\"\<cr>", 'tx') 616 call assert_match('^"e \~.*\<' . whoami . '\>', @:) 617 endif 618 elseif has('win32') 619 " Just in case: check that the system has an Administrator account. 620 let names = system('net user') 621 if names =~ 'Administrator' 622 " Trying completion of :e ~A should complete to Administrator. 623 " There could be other names starting with "A" before Administrator. 624 call feedkeys(':e ~A' . "\<c-a>\<c-B>\"\<cr>", 'tx') 625 call assert_match('^"e \~.*Administrator', @:) 626 endif 627 else 628 throw 'Skipped: does not work on this platform' 629 endif 630endfunc 631 632func Test_cmdline_complete_bang() 633 CheckExecutable whoami 634 call feedkeys(":!whoam\<C-A>\<C-B>\"\<CR>", 'tx') 635 call assert_match('^".*\<whoami\>', @:) 636endfunc 637 638func Test_cmdline_complete_languages() 639 let lang = substitute(execute('language time'), '.*"\(.*\)"$', '\1', '') 640 call assert_equal(lang, v:lc_time) 641 642 let lang = substitute(execute('language ctype'), '.*"\(.*\)"$', '\1', '') 643 call assert_equal(lang, v:ctype) 644 645 let lang = substitute(execute('language collate'), '.*"\(.*\)"$', '\1', '') 646 call assert_equal(lang, v:collate) 647 648 let lang = substitute(execute('language messages'), '.*"\(.*\)"$', '\1', '') 649 call assert_equal(lang, v:lang) 650 651 call feedkeys(":language \<c-a>\<c-b>\"\<cr>", 'tx') 652 call assert_match('^"language .*\<collate\>.*\<ctype\>.*\<messages\>.*\<time\>', @:) 653 654 call assert_match('^"language .*\<' . lang . '\>', @:) 655 656 call feedkeys(":language messages \<c-a>\<c-b>\"\<cr>", 'tx') 657 call assert_match('^"language .*\<' . lang . '\>', @:) 658 659 call feedkeys(":language ctype \<c-a>\<c-b>\"\<cr>", 'tx') 660 call assert_match('^"language .*\<' . lang . '\>', @:) 661 662 call feedkeys(":language time \<c-a>\<c-b>\"\<cr>", 'tx') 663 call assert_match('^"language .*\<' . lang . '\>', @:) 664 665 call feedkeys(":language collate \<c-a>\<c-b>\"\<cr>", 'tx') 666 call assert_match('^"language .*\<' . lang . '\>', @:) 667endfunc 668 669func Test_cmdline_complete_env_variable() 670 let $X_VIM_TEST_COMPLETE_ENV = 'foo' 671 call feedkeys(":edit $X_VIM_TEST_COMPLETE_E\<C-A>\<C-B>\"\<CR>", 'tx') 672 call assert_match('"edit $X_VIM_TEST_COMPLETE_ENV', @:) 673 unlet $X_VIM_TEST_COMPLETE_ENV 674endfunc 675 676" Test for various command-line completion 677func Test_cmdline_complete_various() 678 " completion for a command starting with a comment 679 call feedkeys(": :|\"\<C-A>\<C-B>\"\<CR>", 'xt') 680 call assert_equal("\" :|\"\<C-A>", @:) 681 682 " completion for a range followed by a comment 683 call feedkeys(":1,2\"\<C-A>\<C-B>\"\<CR>", 'xt') 684 call assert_equal("\"1,2\"\<C-A>", @:) 685 686 " completion for :k command 687 call feedkeys(":ka\<C-A>\<C-B>\"\<CR>", 'xt') 688 call assert_equal("\"ka\<C-A>", @:) 689 690 " completion for short version of the :s command 691 call feedkeys(":sI \<C-A>\<C-B>\"\<CR>", 'xt') 692 call assert_equal("\"sI \<C-A>", @:) 693 694 " completion for :write command 695 call mkdir('Xdir') 696 call writefile(['one'], 'Xdir/Xfile1') 697 let save_cwd = getcwd() 698 cd Xdir 699 call feedkeys(":w >> \<C-A>\<C-B>\"\<CR>", 'xt') 700 call assert_equal("\"w >> Xfile1", @:) 701 call chdir(save_cwd) 702 call delete('Xdir', 'rf') 703 704 " completion for :w ! and :r ! commands 705 call feedkeys(":w !invalid_xyz_cmd\<C-A>\<C-B>\"\<CR>", 'xt') 706 call assert_equal("\"w !invalid_xyz_cmd", @:) 707 call feedkeys(":r !invalid_xyz_cmd\<C-A>\<C-B>\"\<CR>", 'xt') 708 call assert_equal("\"r !invalid_xyz_cmd", @:) 709 710 " completion for :>> and :<< commands 711 call feedkeys(":>>>\<C-A>\<C-B>\"\<CR>", 'xt') 712 call assert_equal("\">>>\<C-A>", @:) 713 call feedkeys(":<<<\<C-A>\<C-B>\"\<CR>", 'xt') 714 call assert_equal("\"<<<\<C-A>", @:) 715 716 " completion for command with +cmd argument 717 call feedkeys(":buffer +/pat Xabc\<C-A>\<C-B>\"\<CR>", 'xt') 718 call assert_equal("\"buffer +/pat Xabc", @:) 719 call feedkeys(":buffer +/pat\<C-A>\<C-B>\"\<CR>", 'xt') 720 call assert_equal("\"buffer +/pat\<C-A>", @:) 721 722 " completion for a command with a trailing comment 723 call feedkeys(":ls \" comment\<C-A>\<C-B>\"\<CR>", 'xt') 724 call assert_equal("\"ls \" comment\<C-A>", @:) 725 726 " completion for a command with a trailing command 727 call feedkeys(":ls | ls\<C-A>\<C-B>\"\<CR>", 'xt') 728 call assert_equal("\"ls | ls", @:) 729 730 " completion for a command with an CTRL-V escaped argument 731 call feedkeys(":ls \<C-V>\<C-V>a\<C-A>\<C-B>\"\<CR>", 'xt') 732 call assert_equal("\"ls \<C-V>a\<C-A>", @:) 733 734 " completion for a command that doesn't take additional arguments 735 call feedkeys(":all abc\<C-A>\<C-B>\"\<CR>", 'xt') 736 call assert_equal("\"all abc\<C-A>", @:) 737 738 " completion for a command with a command modifier 739 call feedkeys(":topleft new\<C-A>\<C-B>\"\<CR>", 'xt') 740 call assert_equal("\"topleft new", @:) 741 742 " completion for the :match command 743 call feedkeys(":match Search /pat/\<C-A>\<C-B>\"\<CR>", 'xt') 744 call assert_equal("\"match Search /pat/\<C-A>", @:) 745 746 " completion for the :s command 747 call feedkeys(":s/from/to/g\<C-A>\<C-B>\"\<CR>", 'xt') 748 call assert_equal("\"s/from/to/g\<C-A>", @:) 749 750 " completion for the :dlist command 751 call feedkeys(":dlist 10 /pat/ a\<C-A>\<C-B>\"\<CR>", 'xt') 752 call assert_equal("\"dlist 10 /pat/ a\<C-A>", @:) 753 754 " completion for the :doautocmd command 755 call feedkeys(":doautocmd User MyCmd a.c\<C-A>\<C-B>\"\<CR>", 'xt') 756 call assert_equal("\"doautocmd User MyCmd a.c\<C-A>", @:) 757 758 " completion of autocmd group after comma 759 call feedkeys(":doautocmd BufNew,BufEn\<C-A>\<C-B>\"\<CR>", 'xt') 760 call assert_equal("\"doautocmd BufNew,BufEnter", @:) 761 762 " completion for the :augroup command 763 augroup XTest 764 augroup END 765 call feedkeys(":augroup X\<C-A>\<C-B>\"\<CR>", 'xt') 766 call assert_equal("\"augroup XTest", @:) 767 augroup! XTest 768 769 " completion for the :unlet command 770 call feedkeys(":unlet one two\<C-A>\<C-B>\"\<CR>", 'xt') 771 call assert_equal("\"unlet one two", @:) 772 773 " completion for the :bdelete command 774 call feedkeys(":bdel a b c\<C-A>\<C-B>\"\<CR>", 'xt') 775 call assert_equal("\"bdel a b c", @:) 776 777 " completion for the :mapclear command 778 call feedkeys(":mapclear \<C-A>\<C-B>\"\<CR>", 'xt') 779 call assert_equal("\"mapclear <buffer>", @:) 780 781 " completion for user defined commands with menu names 782 menu Test.foo :ls<CR> 783 com -nargs=* -complete=menu MyCmd 784 call feedkeys(":MyCmd Te\<C-A>\<C-B>\"\<CR>", 'xt') 785 call assert_equal('"MyCmd Test.', @:) 786 delcom MyCmd 787 unmenu Test 788 789 " completion for user defined commands with mappings 790 mapclear 791 map <F3> :ls<CR> 792 com -nargs=* -complete=mapping MyCmd 793 call feedkeys(":MyCmd <F\<C-A>\<C-B>\"\<CR>", 'xt') 794 call assert_equal('"MyCmd <F3>', @:) 795 mapclear 796 delcom MyCmd 797 798 " completion for :set path= with multiple backslashes 799 call feedkeys(":set path=a\\\\\\ b\<C-A>\<C-B>\"\<CR>", 'xt') 800 call assert_equal('"set path=a\\\ b', @:) 801 802 " completion for :set dir= with a backslash 803 call feedkeys(":set dir=a\\ b\<C-A>\<C-B>\"\<CR>", 'xt') 804 call assert_equal('"set dir=a\ b', @:) 805 806 " completion for the :py3 commands 807 call feedkeys(":py3\<C-A>\<C-B>\"\<CR>", 'xt') 808 call assert_equal('"py3 py3do py3file', @:) 809 810 " redir @" is not the start of a comment. So complete after that 811 call feedkeys(":redir @\" | cwin\t\<C-B>\"\<CR>", 'xt') 812 call assert_equal('"redir @" | cwindow', @:) 813 814 " completion after a backtick 815 call feedkeys(":e `a1b2c\t\<C-B>\"\<CR>", 'xt') 816 call assert_equal('"e `a1b2c', @:) 817 818 " completion for :language command with an invalid argument 819 call feedkeys(":language dummy \t\<C-B>\"\<CR>", 'xt') 820 call assert_equal("\"language dummy \t", @:) 821 822 " completion for commands after a :global command 823 call feedkeys(":g/a\\xb/clearj\t\<C-B>\"\<CR>", 'xt') 824 call assert_equal('"g/a\xb/clearjumps', @:) 825 826 " completion with ambiguous user defined commands 827 com TCmd1 echo 'TCmd1' 828 com TCmd2 echo 'TCmd2' 829 call feedkeys(":TCmd \t\<C-B>\"\<CR>", 'xt') 830 call assert_equal('"TCmd ', @:) 831 delcom TCmd1 832 delcom TCmd2 833 834 " completion after a range followed by a pipe (|) character 835 call feedkeys(":1,10 | chist\t\<C-B>\"\<CR>", 'xt') 836 call assert_equal('"1,10 | chistory', @:) 837 838 " use <Esc> as the 'wildchar' for completion 839 set wildchar=<Esc> 840 call feedkeys(":g/a\\xb/clearj\<Esc>\<C-B>\"\<CR>", 'xt') 841 call assert_equal('"g/a\xb/clearjumps', @:) 842 " pressing <esc> twice should cancel the command 843 call feedkeys(":chist\<Esc>\<Esc>", 'xt') 844 call assert_equal('"g/a\xb/clearjumps', @:) 845 set wildchar& 846endfunc 847 848func Test_cmdline_write_alternatefile() 849 new 850 call setline('.', ['one', 'two']) 851 f foo.txt 852 new 853 f #-A 854 call assert_equal('foo.txt-A', expand('%')) 855 f #<-B.txt 856 call assert_equal('foo-B.txt', expand('%')) 857 f %< 858 call assert_equal('foo-B', expand('%')) 859 new 860 call assert_fails('f #<', 'E95:') 861 bw! 862 f foo-B.txt 863 f %<-A 864 call assert_equal('foo-B-A', expand('%')) 865 bw! 866 bw! 867endfunc 868 869" using a leading backslash here 870set cpo+=C 871 872func Test_cmdline_search_range() 873 new 874 call setline(1, ['a', 'b', 'c', 'd']) 875 /d 876 1,\/s/b/B/ 877 call assert_equal('B', getline(2)) 878 879 /a 880 $ 881 \?,4s/c/C/ 882 call assert_equal('C', getline(3)) 883 884 call setline(1, ['a', 'b', 'c', 'd']) 885 %s/c/c/ 886 1,\&s/b/B/ 887 call assert_equal('B', getline(2)) 888 889 let @/ = 'apple' 890 call assert_fails('\/print', ['E486:.*apple']) 891 892 bwipe! 893endfunc 894 895" Test for the tick mark (') in an excmd range 896func Test_tick_mark_in_range() 897 " If only the tick is passed as a range and no command is specified, there 898 " should not be an error 899 call feedkeys(":'\<CR>", 'xt') 900 call assert_equal("'", getreg(':')) 901 call assert_fails("',print", 'E78:') 902endfunc 903 904" Test for using a line number followed by a search pattern as range 905func Test_lnum_and_pattern_as_range() 906 new 907 call setline(1, ['foo 1', 'foo 2', 'foo 3']) 908 let @" = '' 909 2/foo/yank 910 call assert_equal("foo 3\n", @") 911 call assert_equal(1, line('.')) 912 close! 913endfunc 914 915" Tests for getcmdline(), getcmdpos() and getcmdtype() 916func Check_cmdline(cmdtype) 917 call assert_equal('MyCmd a', getcmdline()) 918 call assert_equal(8, getcmdpos()) 919 call assert_equal(a:cmdtype, getcmdtype()) 920 return '' 921endfunc 922 923set cpo& 924 925func Test_getcmdtype() 926 call feedkeys(":MyCmd a\<C-R>=Check_cmdline(':')\<CR>\<Esc>", "xt") 927 928 let cmdtype = '' 929 debuggreedy 930 call feedkeys(":debug echo 'test'\<CR>", "t") 931 call feedkeys("let cmdtype = \<C-R>=string(getcmdtype())\<CR>\<CR>", "t") 932 call feedkeys("cont\<CR>", "xt") 933 0debuggreedy 934 call assert_equal('>', cmdtype) 935 936 call feedkeys("/MyCmd a\<C-R>=Check_cmdline('/')\<CR>\<Esc>", "xt") 937 call feedkeys("?MyCmd a\<C-R>=Check_cmdline('?')\<CR>\<Esc>", "xt") 938 939 call feedkeys(":call input('Answer?')\<CR>", "t") 940 call feedkeys("MyCmd a\<C-R>=Check_cmdline('@')\<CR>\<C-C>", "xt") 941 942 call feedkeys(":insert\<CR>MyCmd a\<C-R>=Check_cmdline('-')\<CR>\<Esc>", "xt") 943 944 cnoremap <expr> <F6> Check_cmdline('=') 945 call feedkeys("a\<C-R>=MyCmd a\<F6>\<Esc>\<Esc>", "xt") 946 cunmap <F6> 947 948 call assert_equal('', getcmdline()) 949endfunc 950 951func Test_getcmdwintype() 952 call feedkeys("q/:let a = getcmdwintype()\<CR>:q\<CR>", 'x!') 953 call assert_equal('/', a) 954 955 call feedkeys("q?:let a = getcmdwintype()\<CR>:q\<CR>", 'x!') 956 call assert_equal('?', a) 957 958 call feedkeys("q::let a = getcmdwintype()\<CR>:q\<CR>", 'x!') 959 call assert_equal(':', a) 960 961 call feedkeys(":\<C-F>:let a = getcmdwintype()\<CR>:q\<CR>", 'x!') 962 call assert_equal(':', a) 963 964 call assert_equal('', getcmdwintype()) 965endfunc 966 967func Test_getcmdwin_autocmd() 968 let s:seq = [] 969 augroup CmdWin 970 au WinEnter * call add(s:seq, 'WinEnter ' .. win_getid()) 971 au WinLeave * call add(s:seq, 'WinLeave ' .. win_getid()) 972 au BufEnter * call add(s:seq, 'BufEnter ' .. bufnr()) 973 au BufLeave * call add(s:seq, 'BufLeave ' .. bufnr()) 974 au CmdWinEnter * call add(s:seq, 'CmdWinEnter ' .. win_getid()) 975 au CmdWinLeave * call add(s:seq, 'CmdWinLeave ' .. win_getid()) 976 977 let org_winid = win_getid() 978 let org_bufnr = bufnr() 979 call feedkeys("q::let a = getcmdwintype()\<CR>:let s:cmd_winid = win_getid()\<CR>:let s:cmd_bufnr = bufnr()\<CR>:q\<CR>", 'x!') 980 call assert_equal(':', a) 981 call assert_equal([ 982 \ 'WinLeave ' .. org_winid, 983 \ 'WinEnter ' .. s:cmd_winid, 984 \ 'BufLeave ' .. org_bufnr, 985 \ 'BufEnter ' .. s:cmd_bufnr, 986 \ 'CmdWinEnter ' .. s:cmd_winid, 987 \ 'CmdWinLeave ' .. s:cmd_winid, 988 \ 'BufLeave ' .. s:cmd_bufnr, 989 \ 'WinLeave ' .. s:cmd_winid, 990 \ 'WinEnter ' .. org_winid, 991 \ 'BufEnter ' .. org_bufnr, 992 \ ], s:seq) 993 994 au! 995 augroup END 996endfunc 997 998func Test_verbosefile() 999 set verbosefile=Xlog 1000 echomsg 'foo' 1001 echomsg 'bar' 1002 set verbosefile= 1003 let log = readfile('Xlog') 1004 call assert_match("foo\nbar", join(log, "\n")) 1005 call delete('Xlog') 1006 call mkdir('Xdir') 1007 call assert_fails('set verbosefile=Xdir', ['E484:.*Xdir', 'E474:']) 1008 call delete('Xdir', 'd') 1009endfunc 1010 1011func Test_verbose_option() 1012 CheckScreendump 1013 1014 let lines =<< trim [SCRIPT] 1015 command DoSomething echo 'hello' |set ts=4 |let v = '123' |echo v 1016 call feedkeys("\r", 't') " for the hit-enter prompt 1017 set verbose=20 1018 [SCRIPT] 1019 call writefile(lines, 'XTest_verbose') 1020 1021 let buf = RunVimInTerminal('-S XTest_verbose', {'rows': 12}) 1022 call TermWait(buf, 50) 1023 call term_sendkeys(buf, ":DoSomething\<CR>") 1024 call VerifyScreenDump(buf, 'Test_verbose_option_1', {}) 1025 1026 " clean up 1027 call StopVimInTerminal(buf) 1028 call delete('XTest_verbose') 1029endfunc 1030 1031func Test_setcmdpos() 1032 func InsertTextAtPos(text, pos) 1033 call assert_equal(0, setcmdpos(a:pos)) 1034 return a:text 1035 endfunc 1036 1037 " setcmdpos() with position in the middle of the command line. 1038 call feedkeys(":\"12\<C-R>=InsertTextAtPos('a', 3)\<CR>b\<CR>", 'xt') 1039 call assert_equal('"1ab2', @:) 1040 1041 call feedkeys(":\"12\<C-R>\<C-R>=InsertTextAtPos('a', 3)\<CR>b\<CR>", 'xt') 1042 call assert_equal('"1b2a', @:) 1043 1044 " setcmdpos() with position beyond the end of the command line. 1045 call feedkeys(":\"12\<C-B>\<C-R>=InsertTextAtPos('a', 10)\<CR>b\<CR>", 'xt') 1046 call assert_equal('"12ab', @:) 1047 1048 " setcmdpos() returns 1 when not editing the command line. 1049 call assert_equal(1, 3->setcmdpos()) 1050endfunc 1051 1052func Test_cmdline_overstrike() 1053 let encodings = ['latin1', 'utf8'] 1054 let encoding_save = &encoding 1055 1056 for e in encodings 1057 exe 'set encoding=' . e 1058 1059 " Test overstrike in the middle of the command line. 1060 call feedkeys(":\"01234\<home>\<right>\<right>ab\<right>\<insert>cd\<enter>", 'xt') 1061 call assert_equal('"0ab1cd4', @:, e) 1062 1063 " Test overstrike going beyond end of command line. 1064 call feedkeys(":\"01234\<home>\<right>\<right>ab\<right>\<insert>cdefgh\<enter>", 'xt') 1065 call assert_equal('"0ab1cdefgh', @:, e) 1066 1067 " Test toggling insert/overstrike a few times. 1068 call feedkeys(":\"01234\<home>\<right>ab\<right>\<insert>cd\<right>\<insert>ef\<enter>", 'xt') 1069 call assert_equal('"ab0cd3ef4', @:, e) 1070 endfor 1071 1072 " Test overstrike with multi-byte characters. 1073 call feedkeys(":\"テキストエディタ\<home>\<right>\<right>ab\<right>\<insert>cd\<enter>", 'xt') 1074 call assert_equal('"テabキcdエディタ', @:, e) 1075 1076 let &encoding = encoding_save 1077endfunc 1078 1079func Test_cmdwin_bug() 1080 let winid = win_getid() 1081 sp 1082 try 1083 call feedkeys("q::call win_gotoid(" .. winid .. ")\<CR>:q\<CR>", 'x!') 1084 catch /^Vim\%((\a\+)\)\=:E11/ 1085 endtry 1086 bw! 1087endfunc 1088 1089func Test_cmdwin_restore() 1090 CheckScreendump 1091 1092 let lines =<< trim [SCRIPT] 1093 call setline(1, range(30)) 1094 2split 1095 [SCRIPT] 1096 call writefile(lines, 'XTest_restore') 1097 1098 let buf = RunVimInTerminal('-S XTest_restore', {'rows': 12}) 1099 call TermWait(buf, 50) 1100 call term_sendkeys(buf, "q:") 1101 call VerifyScreenDump(buf, 'Test_cmdwin_restore_1', {}) 1102 1103 " normal restore 1104 call term_sendkeys(buf, ":q\<CR>") 1105 call VerifyScreenDump(buf, 'Test_cmdwin_restore_2', {}) 1106 1107 " restore after setting 'lines' with one window 1108 call term_sendkeys(buf, ":close\<CR>") 1109 call term_sendkeys(buf, "q:") 1110 call term_sendkeys(buf, ":set lines=18\<CR>") 1111 call term_sendkeys(buf, ":q\<CR>") 1112 call VerifyScreenDump(buf, 'Test_cmdwin_restore_3', {}) 1113 1114 " clean up 1115 call StopVimInTerminal(buf) 1116 call delete('XTest_restore') 1117endfunc 1118 1119func Test_buffers_lastused() 1120 " check that buffers are sorted by time when wildmode has lastused 1121 call test_settime(1550020000) " middle 1122 edit bufa 1123 enew 1124 call test_settime(1550030000) " newest 1125 edit bufb 1126 enew 1127 call test_settime(1550010000) " oldest 1128 edit bufc 1129 enew 1130 call test_settime(0) 1131 enew 1132 1133 call assert_equal(['bufa', 'bufb', 'bufc'], 1134 \ getcompletion('', 'buffer')) 1135 1136 let save_wildmode = &wildmode 1137 set wildmode=full:lastused 1138 1139 let cap = "\<c-r>=execute('let X=getcmdline()')\<cr>" 1140 call feedkeys(":b \<tab>" .. cap .. "\<esc>", 'xt') 1141 call assert_equal('b bufb', X) 1142 call feedkeys(":b \<tab>\<tab>" .. cap .. "\<esc>", 'xt') 1143 call assert_equal('b bufa', X) 1144 call feedkeys(":b \<tab>\<tab>\<tab>" .. cap .. "\<esc>", 'xt') 1145 call assert_equal('b bufc', X) 1146 enew 1147 1148 edit other 1149 call feedkeys(":b \<tab>" .. cap .. "\<esc>", 'xt') 1150 call assert_equal('b bufb', X) 1151 call feedkeys(":b \<tab>\<tab>" .. cap .. "\<esc>", 'xt') 1152 call assert_equal('b bufa', X) 1153 call feedkeys(":b \<tab>\<tab>\<tab>" .. cap .. "\<esc>", 'xt') 1154 call assert_equal('b bufc', X) 1155 enew 1156 1157 let &wildmode = save_wildmode 1158 1159 bwipeout bufa 1160 bwipeout bufb 1161 bwipeout bufc 1162endfunc 1163 1164func Test_cmdwin_feedkeys() 1165 " This should not generate E488 1166 call feedkeys("q:\<CR>", 'x') 1167 " Using feedkeys with q: only should automatically close the cmd window 1168 call feedkeys('q:', 'xt') 1169 call assert_equal(1, winnr('$')) 1170 call assert_equal('', getcmdwintype()) 1171endfunc 1172 1173" Tests for the issues fixed in 7.4.441. 1174" When 'cedit' is set to Ctrl-C, opening the command window hangs Vim 1175func Test_cmdwin_cedit() 1176 exe "set cedit=\<C-c>" 1177 normal! : 1178 call assert_equal(1, winnr('$')) 1179 1180 let g:cmd_wintype = '' 1181 func CmdWinType() 1182 let g:cmd_wintype = getcmdwintype() 1183 let g:wintype = win_gettype() 1184 return '' 1185 endfunc 1186 1187 call feedkeys("\<C-c>a\<C-R>=CmdWinType()\<CR>\<CR>") 1188 echo input('') 1189 call assert_equal('@', g:cmd_wintype) 1190 call assert_equal('command', g:wintype) 1191 1192 set cedit&vim 1193 delfunc CmdWinType 1194endfunc 1195 1196" Test for CmdwinEnter autocmd 1197func Test_cmdwin_autocmd() 1198 augroup CmdWin 1199 au! 1200 autocmd CmdwinEnter * startinsert 1201 augroup END 1202 1203 call assert_fails('call feedkeys("q:xyz\<CR>", "xt")', 'E492:') 1204 call assert_equal('xyz', @:) 1205 1206 augroup CmdWin 1207 au! 1208 augroup END 1209 augroup! CmdWin 1210endfunc 1211 1212func Test_cmdlineclear_tabenter() 1213 CheckScreendump 1214 1215 let lines =<< trim [SCRIPT] 1216 call setline(1, range(30)) 1217 [SCRIPT] 1218 1219 call writefile(lines, 'XtestCmdlineClearTabenter') 1220 let buf = RunVimInTerminal('-S XtestCmdlineClearTabenter', #{rows: 10}) 1221 call TermWait(buf, 25) 1222 " in one tab make the command line higher with CTRL-W - 1223 call term_sendkeys(buf, ":tabnew\<cr>\<C-w>-\<C-w>-gtgt") 1224 call VerifyScreenDump(buf, 'Test_cmdlineclear_tabenter', {}) 1225 1226 call StopVimInTerminal(buf) 1227 call delete('XtestCmdlineClearTabenter') 1228endfunc 1229 1230" Test for failure in expanding special keywords in cmdline 1231func Test_cmdline_expand_special() 1232 %bwipe! 1233 call assert_fails('e #', 'E499:') 1234 call assert_fails('e <afile>', 'E495:') 1235 call assert_fails('e <abuf>', 'E496:') 1236 call assert_fails('e <amatch>', 'E497:') 1237endfunc 1238 1239func Test_cmdwin_jump_to_win() 1240 call assert_fails('call feedkeys("q:\<C-W>\<C-W>\<CR>", "xt")', 'E11:') 1241 new 1242 set modified 1243 call assert_fails('call feedkeys("q/:qall\<CR>", "xt")', ['E37:', 'E162:']) 1244 close! 1245 call feedkeys("q/:close\<CR>", "xt") 1246 call assert_equal(1, winnr('$')) 1247 call feedkeys("q/:exit\<CR>", "xt") 1248 call assert_equal(1, winnr('$')) 1249 1250 " opening command window twice should fail 1251 call assert_beeps('call feedkeys("q:q:\<CR>\<CR>", "xt")') 1252 call assert_equal(1, winnr('$')) 1253endfunc 1254 1255func Test_cmdwin_interrupted() 1256 CheckScreendump 1257 1258 " aborting the :smile output caused the cmdline window to use the current 1259 " buffer. 1260 let lines =<< trim [SCRIPT] 1261 au WinNew * smile 1262 [SCRIPT] 1263 call writefile(lines, 'XTest_cmdwin') 1264 1265 let buf = RunVimInTerminal('-S XTest_cmdwin', {'rows': 18}) 1266 " open cmdwin 1267 call term_sendkeys(buf, "q:") 1268 call WaitForAssert({-> assert_match('-- More --', term_getline(buf, 18))}) 1269 " quit more prompt for :smile command 1270 call term_sendkeys(buf, "q") 1271 call WaitForAssert({-> assert_match('^$', term_getline(buf, 18))}) 1272 " execute a simple command 1273 call term_sendkeys(buf, "aecho 'done'\<CR>") 1274 call VerifyScreenDump(buf, 'Test_cmdwin_interrupted', {}) 1275 1276 " clean up 1277 call StopVimInTerminal(buf) 1278 call delete('XTest_cmdwin') 1279endfunc 1280 1281" Test for backtick expression in the command line 1282func Test_cmd_backtick() 1283 %argd 1284 argadd `=['a', 'b', 'c']` 1285 call assert_equal(['a', 'b', 'c'], argv()) 1286 %argd 1287endfunc 1288 1289" Test for the :! command 1290func Test_cmd_bang() 1291 CheckUnix 1292 1293 let lines =<< trim [SCRIPT] 1294 " Test for no previous command 1295 call assert_fails('!!', 'E34:') 1296 set nomore 1297 " Test for cmdline expansion with :! 1298 call setline(1, 'foo!') 1299 silent !echo <cWORD> > Xfile.out 1300 call assert_equal(['foo!'], readfile('Xfile.out')) 1301 " Test for using previous command 1302 silent !echo \! ! 1303 call assert_equal(['! echo foo!'], readfile('Xfile.out')) 1304 call writefile(v:errors, 'Xresult') 1305 call delete('Xfile.out') 1306 qall! 1307 [SCRIPT] 1308 call writefile(lines, 'Xscript') 1309 if RunVim([], [], '--clean -S Xscript') 1310 call assert_equal([], readfile('Xresult')) 1311 endif 1312 call delete('Xscript') 1313 call delete('Xresult') 1314endfunc 1315 1316" Test error: "E135: *Filter* Autocommands must not change current buffer" 1317func Test_cmd_bang_E135() 1318 new 1319 call setline(1, ['a', 'b', 'c', 'd']) 1320 augroup test_cmd_filter_E135 1321 au! 1322 autocmd FilterReadPost * help 1323 augroup END 1324 call assert_fails('2,3!echo "x"', 'E135:') 1325 1326 augroup test_cmd_filter_E135 1327 au! 1328 augroup END 1329 %bwipe! 1330endfunc 1331 1332" Test for using ~ for home directory in cmdline completion matches 1333func Test_cmdline_expand_home() 1334 call mkdir('Xdir') 1335 call writefile([], 'Xdir/Xfile1') 1336 call writefile([], 'Xdir/Xfile2') 1337 cd Xdir 1338 let save_HOME = $HOME 1339 let $HOME = getcwd() 1340 call feedkeys(":e ~/\<C-A>\<C-B>\"\<CR>", 'xt') 1341 call assert_equal('"e ~/Xfile1 ~/Xfile2', @:) 1342 let $HOME = save_HOME 1343 cd .. 1344 call delete('Xdir', 'rf') 1345endfunc 1346 1347" Test for using CTRL-\ CTRL-G in the command line to go back to normal mode 1348" or insert mode (when 'insertmode' is set) 1349func Test_cmdline_ctrl_g() 1350 new 1351 call setline(1, 'abc') 1352 call cursor(1, 3) 1353 " If command line is entered from insert mode, using C-\ C-G should back to 1354 " insert mode 1355 call feedkeys("i\<C-O>:\<C-\>\<C-G>xy", 'xt') 1356 call assert_equal('abxyc', getline(1)) 1357 call assert_equal(4, col('.')) 1358 1359 " If command line is entered in 'insertmode', using C-\ C-G should back to 1360 " 'insertmode' 1361 call feedkeys(":set im\<cr>\<C-L>:\<C-\>\<C-G>12\<C-L>:set noim\<cr>", 'xt') 1362 call assert_equal('ab12xyc', getline(1)) 1363 close! 1364endfunc 1365 1366" Test for 'wildmode' 1367func Test_wildmode() 1368 func T(a, c, p) 1369 return "oneA\noneB\noneC" 1370 endfunc 1371 command -nargs=1 -complete=custom,T MyCmd 1372 1373 func SaveScreenLine() 1374 let g:Sline = Screenline(&lines - 1) 1375 return '' 1376 endfunc 1377 cnoremap <expr> <F2> SaveScreenLine() 1378 1379 set nowildmenu 1380 set wildmode=full,list 1381 let g:Sline = '' 1382 call feedkeys(":MyCmd \t\t\<F2>\<C-B>\"\<CR>", 'xt') 1383 call assert_equal('oneA oneB oneC', g:Sline) 1384 call assert_equal('"MyCmd oneA', @:) 1385 1386 set wildmode=longest,full 1387 call feedkeys(":MyCmd o\t\<C-B>\"\<CR>", 'xt') 1388 call assert_equal('"MyCmd one', @:) 1389 call feedkeys(":MyCmd o\t\t\t\t\<C-B>\"\<CR>", 'xt') 1390 call assert_equal('"MyCmd oneC', @:) 1391 1392 set wildmode=longest 1393 call feedkeys(":MyCmd one\t\t\<C-B>\"\<CR>", 'xt') 1394 call assert_equal('"MyCmd one', @:) 1395 1396 set wildmode=list:longest 1397 let g:Sline = '' 1398 call feedkeys(":MyCmd \t\<F2>\<C-B>\"\<CR>", 'xt') 1399 call assert_equal('oneA oneB oneC', g:Sline) 1400 call assert_equal('"MyCmd one', @:) 1401 1402 set wildmode="" 1403 call feedkeys(":MyCmd \t\t\<C-B>\"\<CR>", 'xt') 1404 call assert_equal('"MyCmd oneA', @:) 1405 1406 " Test for wildmode=longest with 'fileignorecase' set 1407 set wildmode=longest 1408 set fileignorecase 1409 argadd AAA AAAA AAAAA 1410 call feedkeys(":buffer a\t\<C-B>\"\<CR>", 'xt') 1411 call assert_equal('"buffer AAA', @:) 1412 set fileignorecase& 1413 1414 " Test for listing files with wildmode=list 1415 set wildmode=list 1416 let g:Sline = '' 1417 call feedkeys(":b A\t\t\<F2>\<C-B>\"\<CR>", 'xt') 1418 call assert_equal('AAA AAAA AAAAA', g:Sline) 1419 call assert_equal('"b A', @:) 1420 1421 %argdelete 1422 delcommand MyCmd 1423 delfunc T 1424 delfunc SaveScreenLine 1425 cunmap <F2> 1426 set wildmode& 1427 %bwipe! 1428endfunc 1429 1430" Test for interrupting the command-line completion 1431func Test_interrupt_compl() 1432 func F(lead, cmdl, p) 1433 if a:lead =~ 'tw' 1434 call interrupt() 1435 return 1436 endif 1437 return "one\ntwo\nthree" 1438 endfunc 1439 command -nargs=1 -complete=custom,F Tcmd 1440 1441 set nowildmenu 1442 set wildmode=full 1443 let interrupted = 0 1444 try 1445 call feedkeys(":Tcmd tw\<Tab>\<C-B>\"\<CR>", 'xt') 1446 catch /^Vim:Interrupt$/ 1447 let interrupted = 1 1448 endtry 1449 call assert_equal(1, interrupted) 1450 1451 delcommand Tcmd 1452 delfunc F 1453 set wildmode& 1454endfunc 1455 1456" Test for moving the cursor on the : command line 1457func Test_cmdline_edit() 1458 let str = ":one two\<C-U>" 1459 let str ..= "one two\<C-W>\<C-W>" 1460 let str ..= "four\<BS>\<C-H>\<Del>\<kDel>" 1461 let str ..= "\<Left>five\<Right>" 1462 let str ..= "\<Home>two " 1463 let str ..= "\<C-Left>one " 1464 let str ..= "\<C-Right> three" 1465 let str ..= "\<End>\<S-Left>four " 1466 let str ..= "\<S-Right> six" 1467 let str ..= "\<C-B>\"\<C-E> seven\<CR>" 1468 call feedkeys(str, 'xt') 1469 call assert_equal("\"one two three four five six seven", @:) 1470endfunc 1471 1472" Test for moving the cursor on the / command line in 'rightleft' mode 1473func Test_cmdline_edit_rightleft() 1474 CheckFeature rightleft 1475 set rightleft 1476 set rightleftcmd=search 1477 let str = "/one two\<C-U>" 1478 let str ..= "one two\<C-W>\<C-W>" 1479 let str ..= "four\<BS>\<C-H>\<Del>\<kDel>" 1480 let str ..= "\<Right>five\<Left>" 1481 let str ..= "\<Home>two " 1482 let str ..= "\<C-Right>one " 1483 let str ..= "\<C-Left> three" 1484 let str ..= "\<End>\<S-Right>four " 1485 let str ..= "\<S-Left> six" 1486 let str ..= "\<C-B>\"\<C-E> seven\<CR>" 1487 call assert_fails("call feedkeys(str, 'xt')", 'E486:') 1488 call assert_equal("\"one two three four five six seven", @/) 1489 set rightleftcmd& 1490 set rightleft& 1491endfunc 1492 1493" Test for using <C-\>e in the command line to evaluate an expression 1494func Test_cmdline_expr() 1495 " Evaluate an expression from the beginning of a command line 1496 call feedkeys(":abc\<C-B>\<C-\>e\"\\\"hello\"\<CR>\<CR>", 'xt') 1497 call assert_equal('"hello', @:) 1498 1499 " Use an invalid expression for <C-\>e 1500 call assert_beeps('call feedkeys(":\<C-\>einvalid\<CR>", "tx")') 1501 1502 " Insert literal <CTRL-\> in the command line 1503 call feedkeys(":\"e \<C-\>\<C-Y>\<CR>", 'xt') 1504 call assert_equal("\"e \<C-\>\<C-Y>", @:) 1505endfunc 1506 1507" Test for 'imcmdline' and 'imsearch' 1508" This test doesn't actually test the input method functionality. 1509func Test_cmdline_inputmethod() 1510 new 1511 call setline(1, ['', 'abc', '']) 1512 set imcmdline 1513 1514 call feedkeys(":\"abc\<CR>", 'xt') 1515 call assert_equal("\"abc", @:) 1516 call feedkeys(":\"\<C-^>abc\<C-^>\<CR>", 'xt') 1517 call assert_equal("\"abc", @:) 1518 call feedkeys("/abc\<CR>", 'xt') 1519 call assert_equal([2, 1], [line('.'), col('.')]) 1520 call feedkeys("/\<C-^>abc\<C-^>\<CR>", 'xt') 1521 call assert_equal([2, 1], [line('.'), col('.')]) 1522 1523 set imsearch=2 1524 call cursor(1, 1) 1525 call feedkeys("/abc\<CR>", 'xt') 1526 call assert_equal([2, 1], [line('.'), col('.')]) 1527 call cursor(1, 1) 1528 call feedkeys("/\<C-^>abc\<C-^>\<CR>", 'xt') 1529 call assert_equal([2, 1], [line('.'), col('.')]) 1530 set imdisable 1531 call feedkeys("/\<C-^>abc\<C-^>\<CR>", 'xt') 1532 call assert_equal([2, 1], [line('.'), col('.')]) 1533 set imdisable& 1534 set imsearch& 1535 1536 set imcmdline& 1537 %bwipe! 1538endfunc 1539 1540" Test for recursively getting multiple command line inputs 1541func Test_cmdwin_multi_input() 1542 call feedkeys(":\<C-R>=input('P: ')\<CR>\"cyan\<CR>\<CR>", 'xt') 1543 call assert_equal('"cyan', @:) 1544endfunc 1545 1546" Test for using CTRL-_ in the command line with 'allowrevins' 1547func Test_cmdline_revins() 1548 CheckNotMSWindows 1549 CheckFeature rightleft 1550 call feedkeys(":\"abc\<c-_>\<cr>", 'xt') 1551 call assert_equal("\"abc\<c-_>", @:) 1552 set allowrevins 1553 call feedkeys(":\"abc\<c-_>xyz\<c-_>\<CR>", 'xt') 1554 call assert_equal('"abcñèæ', @:) 1555 set allowrevins& 1556endfunc 1557 1558" Test for typing UTF-8 composing characters in the command line 1559func Test_cmdline_composing_chars() 1560 call feedkeys(":\"\<C-V>u3046\<C-V>u3099\<CR>", 'xt') 1561 call assert_equal('"ゔ', @:) 1562endfunc 1563 1564" Test for normal mode commands not supported in the cmd window 1565func Test_cmdwin_blocked_commands() 1566 call assert_fails('call feedkeys("q:\<C-T>\<CR>", "xt")', 'E11:') 1567 call assert_fails('call feedkeys("q:\<C-]>\<CR>", "xt")', 'E11:') 1568 call assert_fails('call feedkeys("q:\<C-^>\<CR>", "xt")', 'E11:') 1569 call assert_fails('call feedkeys("q:Q\<CR>", "xt")', 'E11:') 1570 call assert_fails('call feedkeys("q:Z\<CR>", "xt")', 'E11:') 1571 call assert_fails('call feedkeys("q:\<F1>\<CR>", "xt")', 'E11:') 1572 call assert_fails('call feedkeys("q:\<C-W>s\<CR>", "xt")', 'E11:') 1573 call assert_fails('call feedkeys("q:\<C-W>v\<CR>", "xt")', 'E11:') 1574 call assert_fails('call feedkeys("q:\<C-W>^\<CR>", "xt")', 'E11:') 1575 call assert_fails('call feedkeys("q:\<C-W>n\<CR>", "xt")', 'E11:') 1576 call assert_fails('call feedkeys("q:\<C-W>z\<CR>", "xt")', 'E11:') 1577 call assert_fails('call feedkeys("q:\<C-W>o\<CR>", "xt")', 'E11:') 1578 call assert_fails('call feedkeys("q:\<C-W>w\<CR>", "xt")', 'E11:') 1579 call assert_fails('call feedkeys("q:\<C-W>j\<CR>", "xt")', 'E11:') 1580 call assert_fails('call feedkeys("q:\<C-W>k\<CR>", "xt")', 'E11:') 1581 call assert_fails('call feedkeys("q:\<C-W>h\<CR>", "xt")', 'E11:') 1582 call assert_fails('call feedkeys("q:\<C-W>l\<CR>", "xt")', 'E11:') 1583 call assert_fails('call feedkeys("q:\<C-W>T\<CR>", "xt")', 'E11:') 1584 call assert_fails('call feedkeys("q:\<C-W>x\<CR>", "xt")', 'E11:') 1585 call assert_fails('call feedkeys("q:\<C-W>r\<CR>", "xt")', 'E11:') 1586 call assert_fails('call feedkeys("q:\<C-W>R\<CR>", "xt")', 'E11:') 1587 call assert_fails('call feedkeys("q:\<C-W>K\<CR>", "xt")', 'E11:') 1588 call assert_fails('call feedkeys("q:\<C-W>}\<CR>", "xt")', 'E11:') 1589 call assert_fails('call feedkeys("q:\<C-W>]\<CR>", "xt")', 'E11:') 1590 call assert_fails('call feedkeys("q:\<C-W>f\<CR>", "xt")', 'E11:') 1591 call assert_fails('call feedkeys("q:\<C-W>d\<CR>", "xt")', 'E11:') 1592 call assert_fails('call feedkeys("q:\<C-W>g\<CR>", "xt")', 'E11:') 1593endfunc 1594 1595" Close the Cmd-line window in insert mode using CTRL-C 1596func Test_cmdwin_insert_mode_close() 1597 %bw! 1598 let s = '' 1599 exe "normal q:a\<C-C>let s='Hello'\<CR>" 1600 call assert_equal('Hello', s) 1601 call assert_equal(1, winnr('$')) 1602endfunc 1603 1604" test that ";" works to find a match at the start of the first line 1605func Test_zero_line_search() 1606 new 1607 call setline(1, ["1, pattern", "2, ", "3, pattern"]) 1608 call cursor(1,1) 1609 0;/pattern/d 1610 call assert_equal(["2, ", "3, pattern"], getline(1,'$')) 1611 q! 1612endfunc 1613 1614func Test_read_shellcmd() 1615 CheckUnix 1616 if executable('ls') 1617 " There should be ls in the $PATH 1618 call feedkeys(":r! l\<c-a>\<c-b>\"\<cr>", 'tx') 1619 call assert_match('^"r! .*\<ls\>', @:) 1620 endif 1621 1622 if executable('rm') 1623 call feedkeys(":r! ++enc=utf-8 r\<c-a>\<c-b>\"\<cr>", 'tx') 1624 call assert_notmatch('^"r!.*\<runtest.vim\>', @:) 1625 call assert_match('^"r!.*\<rm\>', @:) 1626 1627 call feedkeys(":r ++enc=utf-8 !rm\<c-a>\<c-b>\"\<cr>", 'tx') 1628 call assert_notmatch('^"r.*\<runtest.vim\>', @:) 1629 call assert_match('^"r ++enc\S\+ !.*\<rm\>', @:) 1630 endif 1631endfunc 1632 1633" Test for going up and down the directory tree using 'wildmenu' 1634func Test_wildmenu_dirstack() 1635 CheckUnix 1636 %bw! 1637 call mkdir('Xdir1/dir2/dir3', 'p') 1638 call writefile([], 'Xdir1/file1_1.txt') 1639 call writefile([], 'Xdir1/file1_2.txt') 1640 call writefile([], 'Xdir1/dir2/file2_1.txt') 1641 call writefile([], 'Xdir1/dir2/file2_2.txt') 1642 call writefile([], 'Xdir1/dir2/dir3/file3_1.txt') 1643 call writefile([], 'Xdir1/dir2/dir3/file3_2.txt') 1644 cd Xdir1/dir2/dir3 1645 set wildmenu 1646 1647 call feedkeys(":e \<Tab>\<C-B>\"\<CR>", 'xt') 1648 call assert_equal('"e file3_1.txt', @:) 1649 call feedkeys(":e \<Tab>\<Up>\<C-B>\"\<CR>", 'xt') 1650 call assert_equal('"e ../dir3/', @:) 1651 call feedkeys(":e \<Tab>\<Up>\<Up>\<C-B>\"\<CR>", 'xt') 1652 call assert_equal('"e ../../dir2/', @:) 1653 call feedkeys(":e \<Tab>\<Up>\<Up>\<Down>\<C-B>\"\<CR>", 'xt') 1654 call assert_equal('"e ../../dir2/dir3/', @:) 1655 call feedkeys(":e \<Tab>\<Up>\<Up>\<Down>\<Down>\<C-B>\"\<CR>", 'xt') 1656 call assert_equal('"e ../../dir2/dir3/file3_1.txt', @:) 1657 1658 cd - 1659 call delete('Xdir1', 'rf') 1660 set wildmenu& 1661endfunc 1662 1663" vim: shiftwidth=2 sts=2 expandtab 1664