Mercurial > vim
comparison src/testdir/test_cmdline.vim @ 27722:637ccebaf328 v8.2.4387
patch 8.2.4387: command line completion doesn't always work properly
Commit: https://github.com/vim/vim/commit/e3846cf1ebdc4af0b39885153b4703f71a9b919e
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Tue Feb 15 11:35:54 2022 +0000
patch 8.2.4387: command line completion doesn't always work properly
Problem: Command line completion doesn't always work properly.
Solution: Adjust triggering after a "|". Add more tests. (Yegappan
Lakshmanan, closes #9779)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 15 Feb 2022 12:45:04 +0100 |
parents | 9c96612730a0 |
children | 515ce8e07bf2 |
comparison
equal
deleted
inserted
replaced
27721:c6174f84a358 | 27722:637ccebaf328 |
---|---|
262 endfunc | 262 endfunc |
263 | 263 |
264 func Test_match_completion() | 264 func Test_match_completion() |
265 hi Aardig ctermfg=green | 265 hi Aardig ctermfg=green |
266 call feedkeys(":match \<Tab>\<Home>\"\<CR>", 'xt') | 266 call feedkeys(":match \<Tab>\<Home>\"\<CR>", 'xt') |
267 call assert_equal('"match Aardig', getreg(':')) | 267 call assert_equal('"match Aardig', @:) |
268 call feedkeys(":match \<S-Tab>\<Home>\"\<CR>", 'xt') | 268 call feedkeys(":match \<S-Tab>\<Home>\"\<CR>", 'xt') |
269 call assert_equal('"match none', getreg(':')) | 269 call assert_equal('"match none', @:) |
270 call feedkeys(":match | chist\<Tab>\<C-B>\"\<CR>", 'xt') | |
271 call assert_equal('"match | chistory', @:) | |
270 endfunc | 272 endfunc |
271 | 273 |
272 func Test_highlight_completion() | 274 func Test_highlight_completion() |
273 hi Aardig ctermfg=green | 275 hi Aardig ctermfg=green |
274 call feedkeys(":hi \<Tab>\<Home>\"\<CR>", 'xt') | 276 call feedkeys(":hi \<Tab>\<Home>\"\<CR>", 'xt') |
385 call assert_equal([], l) | 387 call assert_equal([], l) |
386 set wildignore=*.vim | 388 set wildignore=*.vim |
387 let l = getcompletion('run', 'file', 1) | 389 let l = getcompletion('run', 'file', 1) |
388 call assert_true(index(l, 'runtest.vim') < 0) | 390 call assert_true(index(l, 'runtest.vim') < 0) |
389 set wildignore& | 391 set wildignore& |
392 " Directory name with space character | |
393 call mkdir('Xdir with space') | |
394 call assert_equal(['Xdir with space/'], getcompletion('Xdir\ w', 'shellcmd')) | |
395 call assert_equal(['./Xdir with space/'], getcompletion('./Xdir', 'shellcmd')) | |
396 call delete('Xdir with space', 'd') | |
390 | 397 |
391 let l = getcompletion('ha', 'filetype') | 398 let l = getcompletion('ha', 'filetype') |
392 call assert_true(index(l, 'hamster') >= 0) | 399 call assert_true(index(l, 'hamster') >= 0) |
393 let l = getcompletion('horse', 'filetype') | 400 let l = getcompletion('horse', 'filetype') |
394 call assert_equal([], l) | 401 call assert_equal([], l) |
606 | 613 |
607 func Test_expand_star_star() | 614 func Test_expand_star_star() |
608 call mkdir('a/b', 'p') | 615 call mkdir('a/b', 'p') |
609 call writefile(['asdfasdf'], 'a/b/fileXname') | 616 call writefile(['asdfasdf'], 'a/b/fileXname') |
610 call feedkeys(":find **/fileXname\<Tab>\<CR>", 'xt') | 617 call feedkeys(":find **/fileXname\<Tab>\<CR>", 'xt') |
611 call assert_equal('find a/b/fileXname', getreg(':')) | 618 call assert_equal('find a/b/fileXname', @:) |
612 bwipe! | 619 bwipe! |
613 call delete('a', 'rf') | 620 call delete('a', 'rf') |
614 endfunc | 621 endfunc |
615 | 622 |
616 func Test_cmdline_paste() | 623 func Test_cmdline_paste() |
740 command! -complete=color -nargs=1 Foo : | 747 command! -complete=color -nargs=1 Foo : |
741 call feedkeys(":Foo \<Tab>\<Home>\"\<cr>", 'tx') | 748 call feedkeys(":Foo \<Tab>\<Home>\"\<cr>", 'tx') |
742 call assert_equal('"Foo blue', @:) | 749 call assert_equal('"Foo blue', @:) |
743 call feedkeys(":Foo b\<Tab>\<Home>\"\<cr>", 'tx') | 750 call feedkeys(":Foo b\<Tab>\<Home>\"\<cr>", 'tx') |
744 call assert_equal('"Foo blue', @:) | 751 call assert_equal('"Foo blue', @:) |
752 call feedkeys(":Foo a b\<Tab>\<Home>\"\<cr>", 'tx') | |
753 call assert_equal('"Foo a blue', @:) | |
754 call feedkeys(":Foo b\\\<Tab>\<Home>\"\<cr>", 'tx') | |
755 call assert_equal('"Foo b\', @:) | |
756 call feedkeys(":Foo b\\x\<Tab>\<Home>\"\<cr>", 'tx') | |
757 call assert_equal('"Foo b\x', @:) | |
745 delcommand Foo | 758 delcommand Foo |
746 endfunc | 759 endfunc |
747 | 760 |
748 func s:ScriptLocalFunction() | 761 func s:ScriptLocalFunction() |
749 echo 'yes' | 762 echo 'yes' |
951 | 964 |
952 " completion for the :match command | 965 " completion for the :match command |
953 call feedkeys(":match Search /pat/\<C-A>\<C-B>\"\<CR>", 'xt') | 966 call feedkeys(":match Search /pat/\<C-A>\<C-B>\"\<CR>", 'xt') |
954 call assert_equal("\"match Search /pat/\<C-A>", @:) | 967 call assert_equal("\"match Search /pat/\<C-A>", @:) |
955 | 968 |
956 " completion for the :s command | |
957 call feedkeys(":s/from/to/g\<C-A>\<C-B>\"\<CR>", 'xt') | |
958 call assert_equal("\"s/from/to/g\<C-A>", @:) | |
959 | |
960 " completion for the :dlist command | |
961 call feedkeys(":dlist 10 /pat/ a\<C-A>\<C-B>\"\<CR>", 'xt') | |
962 call assert_equal("\"dlist 10 /pat/ a\<C-A>", @:) | |
963 | |
964 " completion for the :doautocmd command | 969 " completion for the :doautocmd command |
965 call feedkeys(":doautocmd User MyCmd a.c\<C-A>\<C-B>\"\<CR>", 'xt') | 970 call feedkeys(":doautocmd User MyCmd a.c\<C-A>\<C-B>\"\<CR>", 'xt') |
966 call assert_equal("\"doautocmd User MyCmd a.c\<C-A>", @:) | 971 call assert_equal("\"doautocmd User MyCmd a.c\<C-A>", @:) |
967 | 972 |
968 " completion of autocmd group after comma | 973 " completion of autocmd group after comma |
1066 | 1071 |
1067 " completion after a range followed by a pipe (|) character | 1072 " completion after a range followed by a pipe (|) character |
1068 call feedkeys(":1,10 | chist\t\<C-B>\"\<CR>", 'xt') | 1073 call feedkeys(":1,10 | chist\t\<C-B>\"\<CR>", 'xt') |
1069 call assert_equal('"1,10 | chistory', @:) | 1074 call assert_equal('"1,10 | chistory', @:) |
1070 | 1075 |
1076 " completion after a :global command | |
1077 call feedkeys(":g/a/chist\t\<C-B>\"\<CR>", 'xt') | |
1078 call assert_equal('"g/a/chistory', @:) | |
1079 call feedkeys(":g/a\\/chist\t\<C-B>\"\<CR>", 'xt') | |
1080 call assert_equal("\"g/a\\/chist\t", @:) | |
1081 | |
1071 " use <Esc> as the 'wildchar' for completion | 1082 " use <Esc> as the 'wildchar' for completion |
1072 set wildchar=<Esc> | 1083 set wildchar=<Esc> |
1073 call feedkeys(":g/a\\xb/clearj\<Esc>\<C-B>\"\<CR>", 'xt') | 1084 call feedkeys(":g/a\\xb/clearj\<Esc>\<C-B>\"\<CR>", 'xt') |
1074 call assert_equal('"g/a\xb/clearjumps', @:) | 1085 call assert_equal('"g/a\xb/clearjumps', @:) |
1075 " pressing <esc> twice should cancel the command | 1086 " pressing <esc> twice should cancel the command |
1076 call feedkeys(":chist\<Esc>\<Esc>", 'xt') | 1087 call feedkeys(":chist\<Esc>\<Esc>", 'xt') |
1077 call assert_equal('"g/a\xb/clearjumps', @:) | 1088 call assert_equal('"g/a\xb/clearjumps', @:) |
1078 set wildchar& | 1089 set wildchar& |
1079 | 1090 |
1080 " should be able to complete a file name that starts with a '~'. | |
1081 if has('unix') | 1091 if has('unix') |
1092 " should be able to complete a file name that starts with a '~'. | |
1082 call writefile([], '~Xtest') | 1093 call writefile([], '~Xtest') |
1083 call feedkeys(":e \\~X\<Tab>\<C-B>\"\<CR>", 'xt') | 1094 call feedkeys(":e \\~X\<Tab>\<C-B>\"\<CR>", 'xt') |
1084 call assert_equal('"e \~Xtest', @:) | 1095 call assert_equal('"e \~Xtest', @:) |
1085 call delete('~Xtest') | 1096 call delete('~Xtest') |
1097 | |
1098 " should be able to complete a file name that has a '*' | |
1099 call writefile([], 'Xx*Yy') | |
1100 call feedkeys(":e Xx\*\<Tab>\<C-B>\"\<CR>", 'xt') | |
1101 call assert_equal('"e Xx\*Yy', @:) | |
1102 call delete('Xx*Yy') | |
1086 endif | 1103 endif |
1087 | 1104 |
1088 call feedkeys(":py3f\<Tab>\<C-B>\"\<CR>", 'xt') | 1105 call feedkeys(":py3f\<Tab>\<C-B>\"\<CR>", 'xt') |
1089 call assert_equal('"py3file', @:) | 1106 call assert_equal('"py3file', @:) |
1090 endfunc | 1107 endfunc |
1095 call writefile([], 'XTEST') | 1112 call writefile([], 'XTEST') |
1096 set wildignorecase | 1113 set wildignorecase |
1097 call feedkeys(":e xt\<Tab>\<C-B>\"\<CR>", 'xt') | 1114 call feedkeys(":e xt\<Tab>\<C-B>\"\<CR>", 'xt') |
1098 call assert_equal('"e XTEST', @:) | 1115 call assert_equal('"e XTEST', @:) |
1099 call assert_equal(['XTEST'], getcompletion('xt', 'file')) | 1116 call assert_equal(['XTEST'], getcompletion('xt', 'file')) |
1117 let g:Sline = '' | |
1118 call feedkeys(":e xt\<C-d>\<F4>\<C-B>\"\<CR>", 'xt') | |
1119 call assert_equal('"e xt', @:) | |
1120 call assert_equal('XTEST', g:Sline) | |
1100 set wildignorecase& | 1121 set wildignorecase& |
1101 call delete('XTEST') | 1122 call delete('XTEST') |
1102 endfunc | 1123 endfunc |
1103 | 1124 |
1104 func Test_cmdline_write_alternatefile() | 1125 func Test_cmdline_write_alternatefile() |
1151 " Test for the tick mark (') in an excmd range | 1172 " Test for the tick mark (') in an excmd range |
1152 func Test_tick_mark_in_range() | 1173 func Test_tick_mark_in_range() |
1153 " If only the tick is passed as a range and no command is specified, there | 1174 " If only the tick is passed as a range and no command is specified, there |
1154 " should not be an error | 1175 " should not be an error |
1155 call feedkeys(":'\<CR>", 'xt') | 1176 call feedkeys(":'\<CR>", 'xt') |
1156 call assert_equal("'", getreg(':')) | 1177 call assert_equal("'", @:) |
1157 call assert_fails("',print", 'E78:') | 1178 call assert_fails("',print", 'E78:') |
1158 endfunc | 1179 endfunc |
1159 | 1180 |
1160 " Test for using a line number followed by a search pattern as range | 1181 " Test for using a line number followed by a search pattern as range |
1161 func Test_lnum_and_pattern_as_range() | 1182 func Test_lnum_and_pattern_as_range() |
1723 " non existing file | 1744 " non existing file |
1724 call feedkeys(":e a1b2y3z4\t\<C-B>\"\<CR>", 'xt') | 1745 call feedkeys(":e a1b2y3z4\t\<C-B>\"\<CR>", 'xt') |
1725 call assert_equal('"e a1b2y3z4', @:) | 1746 call assert_equal('"e a1b2y3z4', @:) |
1726 set wildmenu& | 1747 set wildmenu& |
1727 | 1748 |
1749 " Test for longest file name completion with 'fileignorecase' | |
1750 " On MS-Windows, file names are case insensitive. | |
1751 if has('unix') | |
1752 call writefile([], 'XTESTfoo') | |
1753 call writefile([], 'Xtestbar') | |
1754 set nofileignorecase | |
1755 call feedkeys(":e XT\<Tab>\<C-B>\"\<CR>", 'xt') | |
1756 call assert_equal('"e XTESTfoo', @:) | |
1757 call feedkeys(":e Xt\<Tab>\<C-B>\"\<CR>", 'xt') | |
1758 call assert_equal('"e Xtestbar', @:) | |
1759 set fileignorecase | |
1760 call feedkeys(":e XT\<Tab>\<C-B>\"\<CR>", 'xt') | |
1761 call assert_equal('"e Xtest', @:) | |
1762 call feedkeys(":e Xt\<Tab>\<C-B>\"\<CR>", 'xt') | |
1763 call assert_equal('"e Xtest', @:) | |
1764 set fileignorecase& | |
1765 call delete('XTESTfoo') | |
1766 call delete('Xtestbar') | |
1767 endif | |
1768 | |
1728 %argdelete | 1769 %argdelete |
1729 delcommand MyCmd | 1770 delcommand MyCmd |
1730 delfunc T | 1771 delfunc T |
1731 set wildmode& | 1772 set wildmode& |
1732 %bwipe! | 1773 %bwipe! |
1757 set nowildmenu | 1798 set nowildmenu |
1758 set wildmode=full | 1799 set wildmode=full |
1759 let interrupted = 0 | 1800 let interrupted = 0 |
1760 try | 1801 try |
1761 call feedkeys(":Tcmd tw\<Tab>\<C-B>\"\<CR>", 'xt') | 1802 call feedkeys(":Tcmd tw\<Tab>\<C-B>\"\<CR>", 'xt') |
1803 catch /^Vim:Interrupt$/ | |
1804 let interrupted = 1 | |
1805 endtry | |
1806 call assert_equal(1, interrupted) | |
1807 | |
1808 let interrupted = 0 | |
1809 try | |
1810 call feedkeys(":Tcmd tw\<C-d>\<C-B>\"\<CR>", 'xt') | |
1762 catch /^Vim:Interrupt$/ | 1811 catch /^Vim:Interrupt$/ |
1763 let interrupted = 1 | 1812 let interrupted = 1 |
1764 endtry | 1813 endtry |
1765 call assert_equal(1, interrupted) | 1814 call assert_equal(1, interrupted) |
1766 | 1815 |
2334 call assert_equal('"sign define0', @:) | 2383 call assert_equal('"sign define0', @:) |
2335 set nowildmenu wildoptions& | 2384 set nowildmenu wildoptions& |
2336 cunmap <F2> | 2385 cunmap <F2> |
2337 endfunc | 2386 endfunc |
2338 | 2387 |
2388 " Test for completion after a :substitute command followed by a pipe (|) | |
2389 " character | |
2390 func Test_cmdline_complete_substitute() | |
2391 call feedkeys(":s | \t\<C-B>\"\<CR>", 'xt') | |
2392 call assert_equal("\"s | \t", @:) | |
2393 call feedkeys(":s/ | \t\<C-B>\"\<CR>", 'xt') | |
2394 call assert_equal("\"s/ | \t", @:) | |
2395 call feedkeys(":s/one | \t\<C-B>\"\<CR>", 'xt') | |
2396 call assert_equal("\"s/one | \t", @:) | |
2397 call feedkeys(":s/one/ | \t\<C-B>\"\<CR>", 'xt') | |
2398 call assert_equal("\"s/one/ | \t", @:) | |
2399 call feedkeys(":s/one/two | \t\<C-B>\"\<CR>", 'xt') | |
2400 call assert_equal("\"s/one/two | \t", @:) | |
2401 call feedkeys(":s/one/two/ | chist\t\<C-B>\"\<CR>", 'xt') | |
2402 call assert_equal('"s/one/two/ | chistory', @:) | |
2403 call feedkeys(":s/one/two/g \t\<C-B>\"\<CR>", 'xt') | |
2404 call assert_equal("\"s/one/two/g \t", @:) | |
2405 call feedkeys(":s/one/two/g | chist\t\<C-B>\"\<CR>", 'xt') | |
2406 call assert_equal("\"s/one/two/g | chistory", @:) | |
2407 call feedkeys(":s/one/t\\/ | \t\<C-B>\"\<CR>", 'xt') | |
2408 call assert_equal("\"s/one/t\\/ | \t", @:) | |
2409 call feedkeys(":s/one/t\"o/ | chist\t\<C-B>\"\<CR>", 'xt') | |
2410 call assert_equal('"s/one/t"o/ | chistory', @:) | |
2411 call feedkeys(":s/one/t|o/ | chist\t\<C-B>\"\<CR>", 'xt') | |
2412 call assert_equal('"s/one/t|o/ | chistory', @:) | |
2413 call feedkeys(":&\t\<C-B>\"\<CR>", 'xt') | |
2414 call assert_equal("\"&\t", @:) | |
2415 endfunc | |
2416 | |
2417 " Test for the :dlist command completion | |
2418 func Test_cmdline_complete_dlist() | |
2419 call feedkeys(":dlist 10 /pat/ a\<C-A>\<C-B>\"\<CR>", 'xt') | |
2420 call assert_equal("\"dlist 10 /pat/ a\<C-A>", @:) | |
2421 call feedkeys(":dlist 10 /pat/ \t\<C-B>\"\<CR>", 'xt') | |
2422 call assert_equal("\"dlist 10 /pat/ \t", @:) | |
2423 call feedkeys(":dlist 10 /pa\\t/\t\<C-B>\"\<CR>", 'xt') | |
2424 call assert_equal("\"dlist 10 /pa\\t/\t", @:) | |
2425 call feedkeys(":dlist 10 /pat\\\t\<C-B>\"\<CR>", 'xt') | |
2426 call assert_equal("\"dlist 10 /pat\\\t", @:) | |
2427 call feedkeys(":dlist 10 /pat/ | chist\<Tab>\<C-B>\"\<CR>", 'xt') | |
2428 call assert_equal("\"dlist 10 /pat/ | chistory", @:) | |
2429 endfunc | |
2430 | |
2339 " vim: shiftwidth=2 sts=2 expandtab | 2431 " vim: shiftwidth=2 sts=2 expandtab |