Mercurial > vim
comparison src/testdir/test_cmdline.vim @ 27744:515ce8e07bf2 v8.2.4398
patch 8.2.4398: some command completion functions are too long
Commit: https://github.com/vim/vim/commit/b31aec3b9387ed12677dca09069c3ae98c6c7447
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Wed Feb 16 12:44:29 2022 +0000
patch 8.2.4398: some command completion functions are too long
Problem: Some command completion functions are too long.
Solution: Refactor code into separate functions. Add a few more tests.
(Yegappan Lakshmanan, closes #9785)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 16 Feb 2022 13:45:04 +0100 |
parents | 637ccebaf328 |
children | ae38d2e81fca |
comparison
equal
deleted
inserted
replaced
27743:629769fd1ff1 | 27744:515ce8e07bf2 |
---|---|
51 if has('win32') | 51 if has('win32') |
52 " Test for 'completeslash' | 52 " Test for 'completeslash' |
53 set completeslash=backslash | 53 set completeslash=backslash |
54 call feedkeys(":e Xtest\<Tab>\<C-B>\"\<CR>", 'xt') | 54 call feedkeys(":e Xtest\<Tab>\<C-B>\"\<CR>", 'xt') |
55 call assert_equal('"e Xtest\', @:) | 55 call assert_equal('"e Xtest\', @:) |
56 call feedkeys(":e Xtest/\<Tab>\<C-B>\"\<CR>", 'xt') | |
57 call assert_equal('"e Xtest\a.', @:) | |
56 set completeslash=slash | 58 set completeslash=slash |
57 call feedkeys(":e Xtest\<Tab>\<C-B>\"\<CR>", 'xt') | 59 call feedkeys(":e Xtest\<Tab>\<C-B>\"\<CR>", 'xt') |
58 call assert_equal('"e Xtest/', @:) | 60 call assert_equal('"e Xtest/', @:) |
61 call feedkeys(":e Xtest\\\<Tab>\<C-B>\"\<CR>", 'xt') | |
62 call assert_equal('"e Xtest/a.', @:) | |
59 set completeslash& | 63 set completeslash& |
60 endif | 64 endif |
61 | 65 |
62 " Test for displaying the tail with wildcards | 66 " Test for displaying the tail with wildcards |
63 let g:Sline = '' | 67 let g:Sline = '' |
137 cd Xdir1/Xdir2 | 141 cd Xdir1/Xdir2 |
138 call feedkeys(":e ../\<Tab>\<Right>\<Down>\<C-A>\<C-B>\"\<CR>", 'tx') | 142 call feedkeys(":e ../\<Tab>\<Right>\<Down>\<C-A>\<C-B>\"\<CR>", 'tx') |
139 call assert_equal('"e Xtestfile3 Xtestfile4', @:) | 143 call assert_equal('"e Xtestfile3 Xtestfile4', @:) |
140 cd - | 144 cd - |
141 | 145 |
146 " test for wildmenumode() | |
142 cnoremap <expr> <F2> wildmenumode() | 147 cnoremap <expr> <F2> wildmenumode() |
143 call feedkeys(":cd Xdir\<Tab>\<F2>\<C-B>\"\<CR>", 'tx') | 148 call feedkeys(":cd Xdir\<Tab>\<F2>\<C-B>\"\<CR>", 'tx') |
144 call assert_equal('"cd Xdir1/0', @:) | 149 call assert_equal('"cd Xdir1/0', @:) |
145 call feedkeys(":e Xdir1/\<Tab>\<F2>\<C-B>\"\<CR>", 'tx') | 150 call feedkeys(":e Xdir1/\<Tab>\<F2>\<C-B>\"\<CR>", 'tx') |
146 call assert_equal('"e Xdir1/Xdir2/1', @:) | 151 call assert_equal('"e Xdir1/Xdir2/1', @:) |
147 cunmap <F2> | 152 cunmap <F2> |
148 | 153 |
149 " cleanup | 154 " cleanup |
150 %bwipe | 155 %bwipe |
151 call delete('Xdir1/Xdir2/Xtestfile4') | 156 call delete('Xdir1', 'rf') |
152 call delete('Xdir1/Xdir2/Xtestfile3') | |
153 call delete('Xdir1/Xtestfile2') | |
154 call delete('Xdir1/Xtestfile1') | |
155 call delete('Xdir1/Xdir2', 'd') | |
156 call delete('Xdir1', 'd') | |
157 set nowildmenu | 157 set nowildmenu |
158 endfunc | 158 endfunc |
159 | 159 |
160 func Test_wildmenu_screendump() | 160 func Test_wildmenu_screendump() |
161 CheckScreendump | 161 CheckScreendump |
1098 " should be able to complete a file name that has a '*' | 1098 " should be able to complete a file name that has a '*' |
1099 call writefile([], 'Xx*Yy') | 1099 call writefile([], 'Xx*Yy') |
1100 call feedkeys(":e Xx\*\<Tab>\<C-B>\"\<CR>", 'xt') | 1100 call feedkeys(":e Xx\*\<Tab>\<C-B>\"\<CR>", 'xt') |
1101 call assert_equal('"e Xx\*Yy', @:) | 1101 call assert_equal('"e Xx\*Yy', @:) |
1102 call delete('Xx*Yy') | 1102 call delete('Xx*Yy') |
1103 | |
1104 " use a literal star | |
1105 call feedkeys(":e \\*\<Tab>\<C-B>\"\<CR>", 'xt') | |
1106 call assert_equal('"e \*', @:) | |
1103 endif | 1107 endif |
1104 | 1108 |
1105 call feedkeys(":py3f\<Tab>\<C-B>\"\<CR>", 'xt') | 1109 call feedkeys(":py3f\<Tab>\<C-B>\"\<CR>", 'xt') |
1106 call assert_equal('"py3file', @:) | 1110 call assert_equal('"py3file', @:) |
1107 endfunc | 1111 endfunc |
2003 | 2007 |
2004 " Test for going up and down the directory tree using 'wildmenu' | 2008 " Test for going up and down the directory tree using 'wildmenu' |
2005 func Test_wildmenu_dirstack() | 2009 func Test_wildmenu_dirstack() |
2006 CheckUnix | 2010 CheckUnix |
2007 %bw! | 2011 %bw! |
2008 call mkdir('Xdir1/dir2/dir3', 'p') | 2012 call mkdir('Xdir1/dir2/dir3/dir4', 'p') |
2009 call writefile([], 'Xdir1/file1_1.txt') | 2013 call writefile([], 'Xdir1/file1_1.txt') |
2010 call writefile([], 'Xdir1/file1_2.txt') | 2014 call writefile([], 'Xdir1/file1_2.txt') |
2011 call writefile([], 'Xdir1/dir2/file2_1.txt') | 2015 call writefile([], 'Xdir1/dir2/file2_1.txt') |
2012 call writefile([], 'Xdir1/dir2/file2_2.txt') | 2016 call writefile([], 'Xdir1/dir2/file2_2.txt') |
2013 call writefile([], 'Xdir1/dir2/dir3/file3_1.txt') | 2017 call writefile([], 'Xdir1/dir2/dir3/file3_1.txt') |
2014 call writefile([], 'Xdir1/dir2/dir3/file3_2.txt') | 2018 call writefile([], 'Xdir1/dir2/dir3/file3_2.txt') |
2015 cd Xdir1/dir2/dir3 | 2019 call writefile([], 'Xdir1/dir2/dir3/dir4/file4_1.txt') |
2020 call writefile([], 'Xdir1/dir2/dir3/dir4/file4_2.txt') | |
2016 set wildmenu | 2021 set wildmenu |
2017 | 2022 |
2023 cd Xdir1/dir2/dir3/dir4 | |
2018 call feedkeys(":e \<Tab>\<C-B>\"\<CR>", 'xt') | 2024 call feedkeys(":e \<Tab>\<C-B>\"\<CR>", 'xt') |
2019 call assert_equal('"e file3_1.txt', @:) | 2025 call assert_equal('"e file4_1.txt', @:) |
2020 call feedkeys(":e \<Tab>\<Up>\<C-B>\"\<CR>", 'xt') | 2026 call feedkeys(":e \<Tab>\<Up>\<C-B>\"\<CR>", 'xt') |
2021 call assert_equal('"e ../dir3/', @:) | 2027 call assert_equal('"e ../dir4/', @:) |
2022 call feedkeys(":e \<Tab>\<Up>\<Up>\<C-B>\"\<CR>", 'xt') | 2028 call feedkeys(":e \<Tab>\<Up>\<Up>\<C-B>\"\<CR>", 'xt') |
2023 call assert_equal('"e ../../dir2/', @:) | 2029 call assert_equal('"e ../../dir3/', @:) |
2030 call feedkeys(":e \<Tab>\<Up>\<Up>\<Up>\<C-B>\"\<CR>", 'xt') | |
2031 call assert_equal('"e ../../../dir2/', @:) | |
2024 call feedkeys(":e \<Tab>\<Up>\<Up>\<Down>\<C-B>\"\<CR>", 'xt') | 2032 call feedkeys(":e \<Tab>\<Up>\<Up>\<Down>\<C-B>\"\<CR>", 'xt') |
2025 call assert_equal('"e ../../dir2/dir3/', @:) | 2033 call assert_equal('"e ../../dir3/dir4/', @:) |
2026 call feedkeys(":e \<Tab>\<Up>\<Up>\<Down>\<Down>\<C-B>\"\<CR>", 'xt') | 2034 call feedkeys(":e \<Tab>\<Up>\<Up>\<Down>\<Down>\<C-B>\"\<CR>", 'xt') |
2027 call assert_equal('"e ../../dir2/dir3/file3_1.txt', @:) | 2035 call assert_equal('"e ../../dir3/dir4/file4_1.txt', @:) |
2028 | |
2029 cd - | 2036 cd - |
2037 call feedkeys(":e Xdir1/\<Tab>\<Down>\<Down>\<Down>\<C-B>\"\<CR>", 'xt') | |
2038 call assert_equal('"e Xdir1/dir2/dir3/dir4/file4_1.txt', @:) | |
2039 | |
2030 call delete('Xdir1', 'rf') | 2040 call delete('Xdir1', 'rf') |
2031 set wildmenu& | 2041 set wildmenu& |
2032 endfunc | 2042 endfunc |
2033 | 2043 |
2034 " Test for recalling newer or older cmdline from history with <Up>, <Down>, | 2044 " Test for recalling newer or older cmdline from history with <Up>, <Down>, |