Bram Moolenaar | ae3150e | 2016-06-11 23:22:36 +0200 | [diff] [blame] | 1 | " Tests for editing the command line. |
| 2 | |
Bram Moolenaar | 4facea3 | 2019-10-12 20:17:40 +0200 | [diff] [blame] | 3 | source check.vim |
| 4 | source screendump.vim |
Bram Moolenaar | 24ebd83 | 2020-03-16 21:25:24 +0100 | [diff] [blame] | 5 | source view_util.vim |
Bram Moolenaar | c82dd86 | 2020-06-07 17:30:33 +0200 | [diff] [blame] | 6 | source shared.vim |
Bram Moolenaar | fe8e9f6 | 2022-03-16 13:09:15 +0000 | [diff] [blame] | 7 | import './vim9.vim' as v9 |
Bram Moolenaar | 4facea3 | 2019-10-12 20:17:40 +0200 | [diff] [blame] | 8 | |
Yegappan Lakshmanan | 9773db6 | 2022-02-14 11:10:59 +0000 | [diff] [blame] | 9 | func SetUp() |
| 10 | func SaveLastScreenLine() |
| 11 | let g:Sline = Screenline(&lines - 1) |
| 12 | return '' |
| 13 | endfunc |
| 14 | cnoremap <expr> <F4> SaveLastScreenLine() |
| 15 | endfunc |
| 16 | |
| 17 | func TearDown() |
| 18 | delfunc SaveLastScreenLine |
| 19 | cunmap <F4> |
| 20 | endfunc |
| 21 | |
Bram Moolenaar | ae3150e | 2016-06-11 23:22:36 +0200 | [diff] [blame] | 22 | func Test_complete_tab() |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 23 | call writefile(['testfile'], 'Xtestfile', 'D') |
Bram Moolenaar | ae3150e | 2016-06-11 23:22:36 +0200 | [diff] [blame] | 24 | call feedkeys(":e Xtest\t\r", "tx") |
| 25 | call assert_equal('testfile', getline(1)) |
Albert Liu | 6024c04 | 2021-08-27 20:59:35 +0200 | [diff] [blame] | 26 | |
| 27 | " Pressing <Tab> after '%' completes the current file, also on MS-Windows |
| 28 | call feedkeys(":e %\t\r", "tx") |
| 29 | call assert_equal('e Xtestfile', @:) |
Bram Moolenaar | ae3150e | 2016-06-11 23:22:36 +0200 | [diff] [blame] | 30 | endfunc |
| 31 | |
| 32 | func Test_complete_list() |
| 33 | " We can't see the output, but at least we check the code runs properly. |
| 34 | call feedkeys(":e test\<C-D>\r", "tx") |
| 35 | call assert_equal('test', expand('%:t')) |
Bram Moolenaar | 578fe94 | 2020-02-27 21:32:51 +0100 | [diff] [blame] | 36 | |
| 37 | " If a command doesn't support completion, then CTRL-D should be literally |
| 38 | " used. |
| 39 | call feedkeys(":chistory \<C-D>\<C-B>\"\<CR>", 'xt') |
| 40 | call assert_equal("\"chistory \<C-D>", @:) |
Yegappan Lakshmanan | 9773db6 | 2022-02-14 11:10:59 +0000 | [diff] [blame] | 41 | |
| 42 | " Test for displaying the tail of the completion matches |
| 43 | set wildmode=longest,full |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 44 | call mkdir('Xtest', 'R') |
Yegappan Lakshmanan | 9773db6 | 2022-02-14 11:10:59 +0000 | [diff] [blame] | 45 | call writefile([], 'Xtest/a.c') |
| 46 | call writefile([], 'Xtest/a.h') |
| 47 | let g:Sline = '' |
| 48 | call feedkeys(":e Xtest/\<C-D>\<F4>\<C-B>\"\<CR>", 'xt') |
| 49 | call assert_equal('a.c a.h', g:Sline) |
| 50 | call assert_equal('"e Xtest/', @:) |
| 51 | if has('win32') |
| 52 | " Test for 'completeslash' |
| 53 | set completeslash=backslash |
| 54 | call feedkeys(":e Xtest\<Tab>\<C-B>\"\<CR>", 'xt') |
| 55 | call assert_equal('"e Xtest\', @:) |
Yegappan Lakshmanan | b31aec3 | 2022-02-16 12:44:29 +0000 | [diff] [blame] | 56 | call feedkeys(":e Xtest/\<Tab>\<C-B>\"\<CR>", 'xt') |
| 57 | call assert_equal('"e Xtest\a.', @:) |
Yegappan Lakshmanan | 9773db6 | 2022-02-14 11:10:59 +0000 | [diff] [blame] | 58 | set completeslash=slash |
| 59 | call feedkeys(":e Xtest\<Tab>\<C-B>\"\<CR>", 'xt') |
| 60 | call assert_equal('"e Xtest/', @:) |
Yegappan Lakshmanan | b31aec3 | 2022-02-16 12:44:29 +0000 | [diff] [blame] | 61 | call feedkeys(":e Xtest\\\<Tab>\<C-B>\"\<CR>", 'xt') |
| 62 | call assert_equal('"e Xtest/a.', @:) |
Yegappan Lakshmanan | 9773db6 | 2022-02-14 11:10:59 +0000 | [diff] [blame] | 63 | set completeslash& |
| 64 | endif |
| 65 | |
| 66 | " Test for displaying the tail with wildcards |
| 67 | let g:Sline = '' |
| 68 | call feedkeys(":e Xtes?/\<C-D>\<F4>\<C-B>\"\<CR>", 'xt') |
| 69 | call assert_equal('Xtest/a.c Xtest/a.h', g:Sline) |
| 70 | call assert_equal('"e Xtes?/', @:) |
| 71 | let g:Sline = '' |
| 72 | call feedkeys(":e Xtes*/\<C-D>\<F4>\<C-B>\"\<CR>", 'xt') |
| 73 | call assert_equal('Xtest/a.c Xtest/a.h', g:Sline) |
| 74 | call assert_equal('"e Xtes*/', @:) |
| 75 | let g:Sline = '' |
| 76 | call feedkeys(":e Xtes[/\<C-D>\<F4>\<C-B>\"\<CR>", 'xt') |
| 77 | call assert_equal(':e Xtes[/', g:Sline) |
| 78 | call assert_equal('"e Xtes[/', @:) |
| 79 | |
Yegappan Lakshmanan | 9773db6 | 2022-02-14 11:10:59 +0000 | [diff] [blame] | 80 | set wildmode& |
Bram Moolenaar | ae3150e | 2016-06-11 23:22:36 +0200 | [diff] [blame] | 81 | endfunc |
| 82 | |
| 83 | func Test_complete_wildmenu() |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 84 | call mkdir('Xwilddir1/Xdir2', 'pR') |
Bram Moolenaar | 3b0d70f | 2022-08-29 22:31:20 +0100 | [diff] [blame] | 85 | call writefile(['testfile1'], 'Xwilddir1/Xtestfile1') |
| 86 | call writefile(['testfile2'], 'Xwilddir1/Xtestfile2') |
| 87 | call writefile(['testfile3'], 'Xwilddir1/Xdir2/Xtestfile3') |
| 88 | call writefile(['testfile3'], 'Xwilddir1/Xdir2/Xtestfile4') |
Bram Moolenaar | ae3150e | 2016-06-11 23:22:36 +0200 | [diff] [blame] | 89 | set wildmenu |
Bram Moolenaar | 37db642 | 2019-03-28 21:26:23 +0100 | [diff] [blame] | 90 | |
| 91 | " Pressing <Tab> completes, and moves to next files when pressing again. |
Bram Moolenaar | 3b0d70f | 2022-08-29 22:31:20 +0100 | [diff] [blame] | 92 | call feedkeys(":e Xwilddir1/\<Tab>\<Tab>\<CR>", 'tx') |
Bram Moolenaar | 37db642 | 2019-03-28 21:26:23 +0100 | [diff] [blame] | 93 | call assert_equal('testfile1', getline(1)) |
Bram Moolenaar | 3b0d70f | 2022-08-29 22:31:20 +0100 | [diff] [blame] | 94 | call feedkeys(":e Xwilddir1/\<Tab>\<Tab>\<Tab>\<CR>", 'tx') |
Bram Moolenaar | ae3150e | 2016-06-11 23:22:36 +0200 | [diff] [blame] | 95 | call assert_equal('testfile2', getline(1)) |
| 96 | |
Bram Moolenaar | 37db642 | 2019-03-28 21:26:23 +0100 | [diff] [blame] | 97 | " <S-Tab> is like <Tab> but begin with the last match and then go to |
| 98 | " previous. |
Bram Moolenaar | 3b0d70f | 2022-08-29 22:31:20 +0100 | [diff] [blame] | 99 | call feedkeys(":e Xwilddir1/Xtest\<S-Tab>\<CR>", 'tx') |
Bram Moolenaar | 37db642 | 2019-03-28 21:26:23 +0100 | [diff] [blame] | 100 | call assert_equal('testfile2', getline(1)) |
Bram Moolenaar | 3b0d70f | 2022-08-29 22:31:20 +0100 | [diff] [blame] | 101 | call feedkeys(":e Xwilddir1/Xtest\<S-Tab>\<S-Tab>\<CR>", 'tx') |
Bram Moolenaar | 37db642 | 2019-03-28 21:26:23 +0100 | [diff] [blame] | 102 | call assert_equal('testfile1', getline(1)) |
| 103 | |
| 104 | " <Left>/<Right> to move to previous/next file. |
Bram Moolenaar | 3b0d70f | 2022-08-29 22:31:20 +0100 | [diff] [blame] | 105 | call feedkeys(":e Xwilddir1/\<Tab>\<Right>\<CR>", 'tx') |
Bram Moolenaar | 37db642 | 2019-03-28 21:26:23 +0100 | [diff] [blame] | 106 | call assert_equal('testfile1', getline(1)) |
Bram Moolenaar | 3b0d70f | 2022-08-29 22:31:20 +0100 | [diff] [blame] | 107 | call feedkeys(":e Xwilddir1/\<Tab>\<Right>\<Right>\<CR>", 'tx') |
Bram Moolenaar | 37db642 | 2019-03-28 21:26:23 +0100 | [diff] [blame] | 108 | call assert_equal('testfile2', getline(1)) |
Bram Moolenaar | 3b0d70f | 2022-08-29 22:31:20 +0100 | [diff] [blame] | 109 | call feedkeys(":e Xwilddir1/\<Tab>\<Right>\<Right>\<Left>\<CR>", 'tx') |
Bram Moolenaar | 37db642 | 2019-03-28 21:26:23 +0100 | [diff] [blame] | 110 | call assert_equal('testfile1', getline(1)) |
| 111 | |
| 112 | " <Up>/<Down> to go up/down directories. |
Bram Moolenaar | 3b0d70f | 2022-08-29 22:31:20 +0100 | [diff] [blame] | 113 | call feedkeys(":e Xwilddir1/\<Tab>\<Down>\<CR>", 'tx') |
Bram Moolenaar | 37db642 | 2019-03-28 21:26:23 +0100 | [diff] [blame] | 114 | call assert_equal('testfile3', getline(1)) |
Bram Moolenaar | 3b0d70f | 2022-08-29 22:31:20 +0100 | [diff] [blame] | 115 | call feedkeys(":e Xwilddir1/\<Tab>\<Down>\<Up>\<Right>\<CR>", 'tx') |
Bram Moolenaar | 37db642 | 2019-03-28 21:26:23 +0100 | [diff] [blame] | 116 | call assert_equal('testfile1', getline(1)) |
| 117 | |
Bram Moolenaar | 3e112ac | 2020-12-28 13:41:53 +0100 | [diff] [blame] | 118 | " this fails in some Unix GUIs, not sure why |
| 119 | if !has('unix') || !has('gui_running') |
| 120 | " <C-J>/<C-K> mappings to go up/down directories when 'wildcharm' is |
| 121 | " different than 'wildchar'. |
| 122 | set wildcharm=<C-Z> |
| 123 | cnoremap <C-J> <Down><C-Z> |
| 124 | cnoremap <C-K> <Up><C-Z> |
Bram Moolenaar | 3b0d70f | 2022-08-29 22:31:20 +0100 | [diff] [blame] | 125 | call feedkeys(":e Xwilddir1/\<Tab>\<C-J>\<CR>", 'tx') |
Bram Moolenaar | 3e112ac | 2020-12-28 13:41:53 +0100 | [diff] [blame] | 126 | call assert_equal('testfile3', getline(1)) |
Bram Moolenaar | 3b0d70f | 2022-08-29 22:31:20 +0100 | [diff] [blame] | 127 | call feedkeys(":e Xwilddir1/\<Tab>\<C-J>\<C-K>\<CR>", 'tx') |
Bram Moolenaar | 3e112ac | 2020-12-28 13:41:53 +0100 | [diff] [blame] | 128 | call assert_equal('testfile1', getline(1)) |
| 129 | set wildcharm=0 |
| 130 | cunmap <C-J> |
| 131 | cunmap <C-K> |
| 132 | endif |
Bram Moolenaar | b0ac4ea | 2020-12-26 12:06:54 +0100 | [diff] [blame] | 133 | |
Bram Moolenaar | 578fe94 | 2020-02-27 21:32:51 +0100 | [diff] [blame] | 134 | " Test for canceling the wild menu by adding a character |
| 135 | redrawstatus |
Bram Moolenaar | 3b0d70f | 2022-08-29 22:31:20 +0100 | [diff] [blame] | 136 | call feedkeys(":e Xwilddir1/\<Tab>x\<C-B>\"\<CR>", 'xt') |
| 137 | call assert_equal('"e Xwilddir1/Xdir2/x', @:) |
Bram Moolenaar | 578fe94 | 2020-02-27 21:32:51 +0100 | [diff] [blame] | 138 | |
Bram Moolenaar | 8d588cc | 2020-02-25 21:47:45 +0100 | [diff] [blame] | 139 | " Completion using a relative path |
Bram Moolenaar | 3b0d70f | 2022-08-29 22:31:20 +0100 | [diff] [blame] | 140 | cd Xwilddir1/Xdir2 |
Bram Moolenaar | 8d588cc | 2020-02-25 21:47:45 +0100 | [diff] [blame] | 141 | call feedkeys(":e ../\<Tab>\<Right>\<Down>\<C-A>\<C-B>\"\<CR>", 'tx') |
| 142 | call assert_equal('"e Xtestfile3 Xtestfile4', @:) |
| 143 | cd - |
| 144 | |
Yegappan Lakshmanan | b31aec3 | 2022-02-16 12:44:29 +0000 | [diff] [blame] | 145 | " test for wildmenumode() |
Bram Moolenaar | 0e05de4 | 2020-03-25 22:23:46 +0100 | [diff] [blame] | 146 | cnoremap <expr> <F2> wildmenumode() |
Bram Moolenaar | 3b0d70f | 2022-08-29 22:31:20 +0100 | [diff] [blame] | 147 | call feedkeys(":cd Xwilddir\<Tab>\<F2>\<C-B>\"\<CR>", 'tx') |
| 148 | call assert_equal('"cd Xwilddir1/0', @:) |
| 149 | call feedkeys(":e Xwilddir1/\<Tab>\<F2>\<C-B>\"\<CR>", 'tx') |
| 150 | call assert_equal('"e Xwilddir1/Xdir2/1', @:) |
Bram Moolenaar | 0e05de4 | 2020-03-25 22:23:46 +0100 | [diff] [blame] | 151 | cunmap <F2> |
| 152 | |
Yegappan Lakshmanan | 5cffa8d | 2022-03-16 13:33:53 +0000 | [diff] [blame] | 153 | " Test for canceling the wild menu by pressing <PageDown> or <PageUp>. |
| 154 | " After this pressing <Left> or <Right> should not change the selection. |
| 155 | call feedkeys(":sign \<Tab>\<PageDown>\<Left>\<Right>\<C-A>\<C-B>\"\<CR>", 'tx') |
| 156 | call assert_equal('"sign define', @:) |
| 157 | call histadd('cmd', 'TestWildMenu') |
| 158 | call feedkeys(":sign \<Tab>\<PageUp>\<Left>\<Right>\<C-A>\<C-B>\"\<CR>", 'tx') |
| 159 | call assert_equal('"TestWildMenu', @:) |
| 160 | |
Yee Cheng Chin | 209ec90 | 2023-10-17 10:56:25 +0200 | [diff] [blame] | 161 | " Test for Ctrl-E/Ctrl-Y being able to cancel / accept a match |
| 162 | call feedkeys(":sign un zz\<Left>\<Left>\<Left>\<Tab>\<C-E> yy\<C-B>\"\<CR>", 'tx') |
| 163 | call assert_equal('"sign un yy zz', @:) |
| 164 | |
| 165 | call feedkeys(":sign un zz\<Left>\<Left>\<Left>\<Tab>\<Tab>\<C-Y> yy\<C-B>\"\<CR>", 'tx') |
| 166 | call assert_equal('"sign unplace yy zz', @:) |
| 167 | |
Bram Moolenaar | 37db642 | 2019-03-28 21:26:23 +0100 | [diff] [blame] | 168 | " cleanup |
| 169 | %bwipe |
Bram Moolenaar | ae3150e | 2016-06-11 23:22:36 +0200 | [diff] [blame] | 170 | set nowildmenu |
| 171 | endfunc |
Bram Moolenaar | 4b2ce12 | 2020-11-21 21:41:41 +0100 | [diff] [blame] | 172 | |
Bram Moolenaar | a60053b | 2020-09-03 16:50:13 +0200 | [diff] [blame] | 173 | func Test_wildmenu_screendump() |
| 174 | CheckScreendump |
| 175 | |
| 176 | let lines =<< trim [SCRIPT] |
| 177 | set wildmenu hlsearch |
| 178 | [SCRIPT] |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 179 | call writefile(lines, 'XTest_wildmenu', 'D') |
Bram Moolenaar | a60053b | 2020-09-03 16:50:13 +0200 | [diff] [blame] | 180 | |
Yee Cheng Chin | 8f4fb00 | 2023-10-17 10:06:56 +0200 | [diff] [blame] | 181 | " Test simple wildmenu |
Bram Moolenaar | a60053b | 2020-09-03 16:50:13 +0200 | [diff] [blame] | 182 | let buf = RunVimInTerminal('-S XTest_wildmenu', {'rows': 8}) |
| 183 | call term_sendkeys(buf, ":vim\<Tab>") |
| 184 | call VerifyScreenDump(buf, 'Test_wildmenu_1', {}) |
| 185 | |
| 186 | call term_sendkeys(buf, "\<Tab>") |
| 187 | call VerifyScreenDump(buf, 'Test_wildmenu_2', {}) |
| 188 | |
| 189 | call term_sendkeys(buf, "\<Tab>") |
| 190 | call VerifyScreenDump(buf, 'Test_wildmenu_3', {}) |
| 191 | |
Yee Cheng Chin | 8f4fb00 | 2023-10-17 10:06:56 +0200 | [diff] [blame] | 192 | " Looped back to the original value |
Bram Moolenaar | 39f3b14 | 2021-02-14 12:57:36 +0100 | [diff] [blame] | 193 | call term_sendkeys(buf, "\<Tab>\<Tab>") |
Bram Moolenaar | a60053b | 2020-09-03 16:50:13 +0200 | [diff] [blame] | 194 | call VerifyScreenDump(buf, 'Test_wildmenu_4', {}) |
Yee Cheng Chin | 8f4fb00 | 2023-10-17 10:06:56 +0200 | [diff] [blame] | 195 | |
| 196 | " Test that the wild menu is cleared properly |
| 197 | call term_sendkeys(buf, " ") |
| 198 | call VerifyScreenDump(buf, 'Test_wildmenu_5', {}) |
| 199 | |
| 200 | " Test that a different wildchar still works |
| 201 | call term_sendkeys(buf, "\<Esc>:set wildchar=<Esc>\<CR>") |
| 202 | call term_sendkeys(buf, ":vim\<Esc>") |
| 203 | call VerifyScreenDump(buf, 'Test_wildmenu_1', {}) |
| 204 | |
| 205 | " Double-<Esc> is a hard-coded method to escape while wildchar=<Esc>. Make |
| 206 | " sure clean up is properly done in edge case like this. |
Bram Moolenaar | a60053b | 2020-09-03 16:50:13 +0200 | [diff] [blame] | 207 | call term_sendkeys(buf, "\<Esc>") |
Yee Cheng Chin | 8f4fb00 | 2023-10-17 10:06:56 +0200 | [diff] [blame] | 208 | call VerifyScreenDump(buf, 'Test_wildmenu_6', {}) |
Bram Moolenaar | a60053b | 2020-09-03 16:50:13 +0200 | [diff] [blame] | 209 | |
| 210 | " clean up |
| 211 | call StopVimInTerminal(buf) |
Bram Moolenaar | a60053b | 2020-09-03 16:50:13 +0200 | [diff] [blame] | 212 | endfunc |
| 213 | |
zeertzjq | 1830e78 | 2025-03-13 20:29:13 +0100 | [diff] [blame] | 214 | func Test_wildmenu_with_input_func() |
| 215 | CheckScreendump |
| 216 | |
| 217 | let buf = RunVimInTerminal('-c "set wildmenu"', {'rows': 8}) |
| 218 | |
| 219 | call term_sendkeys(buf, ":call input('Command? ', '', 'command')\<CR>") |
| 220 | call VerifyScreenDump(buf, 'Test_wildmenu_input_func_1', {}) |
| 221 | call term_sendkeys(buf, "ech\<Tab>") |
| 222 | call VerifyScreenDump(buf, 'Test_wildmenu_input_func_2', {}) |
| 223 | call term_sendkeys(buf, "\<Space>") |
| 224 | call VerifyScreenDump(buf, 'Test_wildmenu_input_func_3', {}) |
| 225 | call term_sendkeys(buf, "bufn\<Tab>") |
| 226 | call VerifyScreenDump(buf, 'Test_wildmenu_input_func_4', {}) |
| 227 | call term_sendkeys(buf, "\<CR>") |
| 228 | |
| 229 | call term_sendkeys(buf, ":set wildoptions+=pum\<CR>") |
| 230 | |
| 231 | call term_sendkeys(buf, ":call input('Command? ', '', 'command')\<CR>") |
| 232 | call VerifyScreenDump(buf, 'Test_wildmenu_input_func_5', {}) |
| 233 | call term_sendkeys(buf, "ech\<Tab>") |
| 234 | call VerifyScreenDump(buf, 'Test_wildmenu_input_func_6', {}) |
| 235 | call term_sendkeys(buf, "\<Space>") |
| 236 | call VerifyScreenDump(buf, 'Test_wildmenu_input_func_7', {}) |
| 237 | call term_sendkeys(buf, "bufn\<Tab>") |
| 238 | call VerifyScreenDump(buf, 'Test_wildmenu_input_func_8', {}) |
| 239 | call term_sendkeys(buf, "\<CR>") |
| 240 | |
| 241 | " clean up |
| 242 | call StopVimInTerminal(buf) |
| 243 | endfunc |
| 244 | |
Bram Moolenaar | a653e53 | 2022-04-19 11:38:24 +0100 | [diff] [blame] | 245 | func Test_redraw_in_autocmd() |
| 246 | CheckScreendump |
| 247 | |
| 248 | let lines =<< trim END |
| 249 | set cmdheight=2 |
| 250 | autocmd CmdlineChanged * redraw |
| 251 | END |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 252 | call writefile(lines, 'XTest_redraw', 'D') |
Bram Moolenaar | a653e53 | 2022-04-19 11:38:24 +0100 | [diff] [blame] | 253 | |
| 254 | let buf = RunVimInTerminal('-S XTest_redraw', {'rows': 8}) |
| 255 | call term_sendkeys(buf, ":for i in range(3)\<CR>") |
| 256 | call VerifyScreenDump(buf, 'Test_redraw_in_autocmd_1', {}) |
| 257 | |
| 258 | call term_sendkeys(buf, "let i =") |
| 259 | call VerifyScreenDump(buf, 'Test_redraw_in_autocmd_2', {}) |
| 260 | |
| 261 | " clean up |
| 262 | call term_sendkeys(buf, "\<CR>") |
| 263 | call StopVimInTerminal(buf) |
Bram Moolenaar | a653e53 | 2022-04-19 11:38:24 +0100 | [diff] [blame] | 264 | endfunc |
| 265 | |
Bram Moolenaar | bcd6924 | 2022-09-19 21:16:12 +0100 | [diff] [blame] | 266 | func Test_redrawstatus_in_autocmd() |
| 267 | CheckScreendump |
| 268 | |
| 269 | let lines =<< trim END |
zeertzjq | c14bfc3 | 2022-09-20 13:17:57 +0100 | [diff] [blame] | 270 | set laststatus=2 |
| 271 | set statusline=%=:%{getcmdline()} |
zeertzjq | 320d910 | 2022-09-20 17:12:13 +0100 | [diff] [blame] | 272 | autocmd CmdlineChanged * redrawstatus |
Bram Moolenaar | bcd6924 | 2022-09-19 21:16:12 +0100 | [diff] [blame] | 273 | END |
| 274 | call writefile(lines, 'XTest_redrawstatus', 'D') |
| 275 | |
| 276 | let buf = RunVimInTerminal('-S XTest_redrawstatus', {'rows': 8}) |
zeertzjq | c14bfc3 | 2022-09-20 13:17:57 +0100 | [diff] [blame] | 277 | " :redrawstatus is postponed if messages have scrolled |
Bram Moolenaar | bcd6924 | 2022-09-19 21:16:12 +0100 | [diff] [blame] | 278 | call term_sendkeys(buf, ":echo \"one\\ntwo\\nthree\\nfour\"\<CR>") |
| 279 | call term_sendkeys(buf, ":foobar") |
| 280 | call VerifyScreenDump(buf, 'Test_redrawstatus_in_autocmd_1', {}) |
zeertzjq | c14bfc3 | 2022-09-20 13:17:57 +0100 | [diff] [blame] | 281 | " it is not postponed if messages have not scrolled |
zeertzjq | 320d910 | 2022-09-20 17:12:13 +0100 | [diff] [blame] | 282 | call term_sendkeys(buf, "\<Esc>:for in in range(3)") |
zeertzjq | c14bfc3 | 2022-09-20 13:17:57 +0100 | [diff] [blame] | 283 | call VerifyScreenDump(buf, 'Test_redrawstatus_in_autocmd_2', {}) |
zeertzjq | 320d910 | 2022-09-20 17:12:13 +0100 | [diff] [blame] | 284 | " with cmdheight=1 messages have scrolled when typing :endfor |
| 285 | call term_sendkeys(buf, "\<CR>:endfor") |
| 286 | call VerifyScreenDump(buf, 'Test_redrawstatus_in_autocmd_3', {}) |
| 287 | call term_sendkeys(buf, "\<CR>:set cmdheight=2\<CR>") |
| 288 | " with cmdheight=2 messages haven't scrolled when typing :for or :endfor |
| 289 | call term_sendkeys(buf, ":for in in range(3)") |
| 290 | call VerifyScreenDump(buf, 'Test_redrawstatus_in_autocmd_4', {}) |
| 291 | call term_sendkeys(buf, "\<CR>:endfor") |
| 292 | call VerifyScreenDump(buf, 'Test_redrawstatus_in_autocmd_5', {}) |
Bram Moolenaar | bcd6924 | 2022-09-19 21:16:12 +0100 | [diff] [blame] | 293 | |
| 294 | " clean up |
| 295 | call term_sendkeys(buf, "\<CR>") |
| 296 | call StopVimInTerminal(buf) |
| 297 | endfunc |
| 298 | |
Bram Moolenaar | f797e30 | 2022-08-11 13:17:30 +0100 | [diff] [blame] | 299 | func Test_changing_cmdheight() |
| 300 | CheckScreendump |
| 301 | |
| 302 | let lines =<< trim END |
| 303 | set cmdheight=1 laststatus=2 |
nwounkn | 2e48567 | 2024-11-11 21:48:30 +0100 | [diff] [blame] | 304 | func EchoOne() |
| 305 | set laststatus=2 cmdheight=1 |
| 306 | echo 'foo' |
| 307 | echo 'bar' |
| 308 | set cmdheight=2 |
| 309 | endfunc |
Bram Moolenaar | 0816f47 | 2022-10-05 15:42:32 +0100 | [diff] [blame] | 310 | func EchoTwo() |
| 311 | set laststatus=2 |
| 312 | set cmdheight=5 |
| 313 | echo 'foo' |
| 314 | echo 'bar' |
| 315 | set cmdheight=1 |
| 316 | endfunc |
Bram Moolenaar | f797e30 | 2022-08-11 13:17:30 +0100 | [diff] [blame] | 317 | END |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 318 | call writefile(lines, 'XTest_cmdheight', 'D') |
Bram Moolenaar | f797e30 | 2022-08-11 13:17:30 +0100 | [diff] [blame] | 319 | |
| 320 | let buf = RunVimInTerminal('-S XTest_cmdheight', {'rows': 8}) |
| 321 | call term_sendkeys(buf, ":resize -3\<CR>") |
| 322 | call VerifyScreenDump(buf, 'Test_changing_cmdheight_1', {}) |
| 323 | |
Luuk van Baal | e15cbc1 | 2025-01-04 17:18:08 +0100 | [diff] [blame] | 324 | " :resize now also changes 'cmdheight' accordingly |
| 325 | call term_sendkeys(buf, ":set cmdheight+=1\<CR>") |
Bram Moolenaar | f797e30 | 2022-08-11 13:17:30 +0100 | [diff] [blame] | 326 | call VerifyScreenDump(buf, 'Test_changing_cmdheight_2', {}) |
| 327 | |
| 328 | " using more space moves the status line up |
| 329 | call term_sendkeys(buf, ":set cmdheight+=1\<CR>") |
| 330 | call VerifyScreenDump(buf, 'Test_changing_cmdheight_3', {}) |
| 331 | |
| 332 | " reducing cmdheight moves status line down |
Luuk van Baal | c97e869 | 2025-01-06 18:58:21 +0100 | [diff] [blame] | 333 | call term_sendkeys(buf, ":set cmdheight-=3\<CR>") |
Bram Moolenaar | f797e30 | 2022-08-11 13:17:30 +0100 | [diff] [blame] | 334 | call VerifyScreenDump(buf, 'Test_changing_cmdheight_4', {}) |
| 335 | |
Bram Moolenaar | a9a6b03 | 2023-02-05 18:00:42 +0000 | [diff] [blame] | 336 | " reducing window size and then setting cmdheight |
Bram Moolenaar | d4cf9fc | 2022-08-11 14:13:37 +0100 | [diff] [blame] | 337 | call term_sendkeys(buf, ":resize -1\<CR>") |
| 338 | call term_sendkeys(buf, ":set cmdheight=1\<CR>") |
| 339 | call VerifyScreenDump(buf, 'Test_changing_cmdheight_5', {}) |
| 340 | |
Bram Moolenaar | 0816f47 | 2022-10-05 15:42:32 +0100 | [diff] [blame] | 341 | " setting 'cmdheight' works after outputting two messages |
| 342 | call term_sendkeys(buf, ":call EchoTwo()\<CR>") |
| 343 | call VerifyScreenDump(buf, 'Test_changing_cmdheight_6', {}) |
| 344 | |
Luuk van Baal | c97e869 | 2025-01-06 18:58:21 +0100 | [diff] [blame] | 345 | " increasing 'cmdheight' doesn't clear the messages that need hit-enter |
nwounkn | 2e48567 | 2024-11-11 21:48:30 +0100 | [diff] [blame] | 346 | call term_sendkeys(buf, ":call EchoOne()\<CR>") |
| 347 | call VerifyScreenDump(buf, 'Test_changing_cmdheight_7', {}) |
| 348 | |
Luuk van Baal | c97e869 | 2025-01-06 18:58:21 +0100 | [diff] [blame] | 349 | " window commands do not reduce 'cmdheight' to value lower than :set by user |
| 350 | call term_sendkeys(buf, "\<CR>:wincmd _\<CR>") |
| 351 | call VerifyScreenDump(buf, 'Test_changing_cmdheight_8', {}) |
| 352 | |
Bram Moolenaar | f797e30 | 2022-08-11 13:17:30 +0100 | [diff] [blame] | 353 | " clean up |
| 354 | call StopVimInTerminal(buf) |
Bram Moolenaar | f797e30 | 2022-08-11 13:17:30 +0100 | [diff] [blame] | 355 | endfunc |
| 356 | |
Bram Moolenaar | c9f5f73 | 2022-10-06 11:39:06 +0100 | [diff] [blame] | 357 | func Test_cmdheight_tabline() |
| 358 | CheckScreendump |
| 359 | |
| 360 | let buf = RunVimInTerminal('-c "set ls=2" -c "set stal=2" -c "set cmdheight=1"', {'rows': 6}) |
| 361 | call VerifyScreenDump(buf, 'Test_cmdheight_tabline_1', {}) |
| 362 | |
| 363 | " clean up |
| 364 | call StopVimInTerminal(buf) |
| 365 | endfunc |
| 366 | |
Bram Moolenaar | cf5fdf7 | 2017-03-02 23:05:51 +0100 | [diff] [blame] | 367 | func Test_map_completion() |
Bram Moolenaar | cf5fdf7 | 2017-03-02 23:05:51 +0100 | [diff] [blame] | 368 | call feedkeys(":map <unique> <si\<Tab>\<Home>\"\<CR>", 'xt') |
| 369 | call assert_equal('"map <unique> <silent>', getreg(':')) |
| 370 | call feedkeys(":map <script> <un\<Tab>\<Home>\"\<CR>", 'xt') |
| 371 | call assert_equal('"map <script> <unique>', getreg(':')) |
| 372 | call feedkeys(":map <expr> <sc\<Tab>\<Home>\"\<CR>", 'xt') |
| 373 | call assert_equal('"map <expr> <script>', getreg(':')) |
| 374 | call feedkeys(":map <buffer> <e\<Tab>\<Home>\"\<CR>", 'xt') |
| 375 | call assert_equal('"map <buffer> <expr>', getreg(':')) |
| 376 | call feedkeys(":map <nowait> <b\<Tab>\<Home>\"\<CR>", 'xt') |
| 377 | call assert_equal('"map <nowait> <buffer>', getreg(':')) |
| 378 | call feedkeys(":map <special> <no\<Tab>\<Home>\"\<CR>", 'xt') |
| 379 | call assert_equal('"map <special> <nowait>', getreg(':')) |
| 380 | call feedkeys(":map <silent> <sp\<Tab>\<Home>\"\<CR>", 'xt') |
| 381 | call assert_equal('"map <silent> <special>', getreg(':')) |
Bram Moolenaar | 2cb9f02 | 2019-05-03 15:13:57 +0200 | [diff] [blame] | 382 | |
Bram Moolenaar | 1776a28 | 2019-05-03 16:05:41 +0200 | [diff] [blame] | 383 | map <Middle>x middle |
| 384 | |
Bram Moolenaar | 2cb9f02 | 2019-05-03 15:13:57 +0200 | [diff] [blame] | 385 | map ,f commaf |
| 386 | map ,g commaf |
Bram Moolenaar | 1776a28 | 2019-05-03 16:05:41 +0200 | [diff] [blame] | 387 | map <Left> left |
| 388 | map <A-Left>x shiftleft |
Bram Moolenaar | 2cb9f02 | 2019-05-03 15:13:57 +0200 | [diff] [blame] | 389 | call feedkeys(":map ,\<Tab>\<Home>\"\<CR>", 'xt') |
| 390 | call assert_equal('"map ,f', getreg(':')) |
| 391 | call feedkeys(":map ,\<Tab>\<Tab>\<Home>\"\<CR>", 'xt') |
| 392 | call assert_equal('"map ,g', getreg(':')) |
Bram Moolenaar | 1776a28 | 2019-05-03 16:05:41 +0200 | [diff] [blame] | 393 | call feedkeys(":map <L\<Tab>\<Home>\"\<CR>", 'xt') |
| 394 | call assert_equal('"map <Left>', getreg(':')) |
| 395 | call feedkeys(":map <A-Left>\<Tab>\<Home>\"\<CR>", 'xt') |
Bram Moolenaar | 92b9e60 | 2019-05-03 16:49:25 +0200 | [diff] [blame] | 396 | call assert_equal("\"map <A-Left>\<Tab>", getreg(':')) |
zeertzjq | c3a26c6 | 2023-02-17 16:40:20 +0000 | [diff] [blame] | 397 | call feedkeys(":map <M-Left>\<Tab>\<Home>\"\<CR>", 'xt') |
| 398 | call assert_equal("\"map <M-Left>x", getreg(':')) |
Bram Moolenaar | 2cb9f02 | 2019-05-03 15:13:57 +0200 | [diff] [blame] | 399 | unmap ,f |
| 400 | unmap ,g |
Bram Moolenaar | 1776a28 | 2019-05-03 16:05:41 +0200 | [diff] [blame] | 401 | unmap <Left> |
| 402 | unmap <A-Left>x |
Bram Moolenaar | 2cb9f02 | 2019-05-03 15:13:57 +0200 | [diff] [blame] | 403 | |
zeertzjq | c3a26c6 | 2023-02-17 16:40:20 +0000 | [diff] [blame] | 404 | set cpo-=< cpo-=k |
Bram Moolenaar | 2cb9f02 | 2019-05-03 15:13:57 +0200 | [diff] [blame] | 405 | map <Left> left |
| 406 | call feedkeys(":map <L\<Tab>\<Home>\"\<CR>", 'xt') |
| 407 | call assert_equal('"map <Left>', getreg(':')) |
Bram Moolenaar | 1776a28 | 2019-05-03 16:05:41 +0200 | [diff] [blame] | 408 | call feedkeys(":map <M\<Tab>\<Home>\"\<CR>", 'xt') |
Bram Moolenaar | 92b9e60 | 2019-05-03 16:49:25 +0200 | [diff] [blame] | 409 | call assert_equal("\"map <M\<Tab>", getreg(':')) |
zeertzjq | c3a26c6 | 2023-02-17 16:40:20 +0000 | [diff] [blame] | 410 | call feedkeys(":map \<C-V>\<C-V><M\<Tab>\<Home>\"\<CR>", 'xt') |
| 411 | call assert_equal("\"map \<C-V><Middle>x", getreg(':')) |
Bram Moolenaar | 2cb9f02 | 2019-05-03 15:13:57 +0200 | [diff] [blame] | 412 | unmap <Left> |
| 413 | |
| 414 | set cpo+=< |
| 415 | map <Left> left |
Bram Moolenaar | 61df0c7 | 2019-05-03 21:10:36 +0200 | [diff] [blame] | 416 | exe "set t_k6=\<Esc>[17~" |
| 417 | call feedkeys(":map \<Esc>[17~x f6x\<CR>", 'xt') |
Bram Moolenaar | 2cb9f02 | 2019-05-03 15:13:57 +0200 | [diff] [blame] | 418 | call feedkeys(":map <L\<Tab>\<Home>\"\<CR>", 'xt') |
| 419 | call assert_equal('"map <Left>', getreg(':')) |
Bram Moolenaar | 510671a | 2019-05-04 19:26:56 +0200 | [diff] [blame] | 420 | if !has('gui_running') |
| 421 | call feedkeys(":map \<Esc>[17~\<Tab>\<Home>\"\<CR>", 'xt') |
| 422 | call assert_equal("\"map <F6>x", getreg(':')) |
| 423 | endif |
Bram Moolenaar | 2cb9f02 | 2019-05-03 15:13:57 +0200 | [diff] [blame] | 424 | unmap <Left> |
Bram Moolenaar | 61df0c7 | 2019-05-03 21:10:36 +0200 | [diff] [blame] | 425 | call feedkeys(":unmap \<Esc>[17~x\<CR>", 'xt') |
Bram Moolenaar | 2cb9f02 | 2019-05-03 15:13:57 +0200 | [diff] [blame] | 426 | set cpo-=< |
| 427 | |
| 428 | set cpo+=B |
| 429 | map <Left> left |
| 430 | call feedkeys(":map <L\<Tab>\<Home>\"\<CR>", 'xt') |
| 431 | call assert_equal('"map <Left>', getreg(':')) |
| 432 | unmap <Left> |
| 433 | set cpo-=B |
| 434 | |
| 435 | set cpo+=k |
| 436 | map <Left> left |
| 437 | call feedkeys(":map <L\<Tab>\<Home>\"\<CR>", 'xt') |
| 438 | call assert_equal('"map <Left>', getreg(':')) |
| 439 | unmap <Left> |
| 440 | set cpo-=k |
Bram Moolenaar | 1776a28 | 2019-05-03 16:05:41 +0200 | [diff] [blame] | 441 | |
Bram Moolenaar | 531be47 | 2020-09-23 22:38:05 +0200 | [diff] [blame] | 442 | call assert_fails('call feedkeys(":map \\\\%(\<Tab>\<Home>\"\<CR>", "xt")', 'E53:') |
| 443 | |
Bram Moolenaar | 1776a28 | 2019-05-03 16:05:41 +0200 | [diff] [blame] | 444 | unmap <Middle>x |
| 445 | set cpo&vim |
Bram Moolenaar | cf5fdf7 | 2017-03-02 23:05:51 +0100 | [diff] [blame] | 446 | endfunc |
| 447 | |
Bram Moolenaar | 15eedf1 | 2017-01-22 19:25:33 +0100 | [diff] [blame] | 448 | func Test_match_completion() |
Bram Moolenaar | 15eedf1 | 2017-01-22 19:25:33 +0100 | [diff] [blame] | 449 | hi Aardig ctermfg=green |
| 450 | call feedkeys(":match \<Tab>\<Home>\"\<CR>", 'xt') |
Yegappan Lakshmanan | e3846cf | 2022-02-15 11:35:54 +0000 | [diff] [blame] | 451 | call assert_equal('"match Aardig', @:) |
Yee Cheng Chin | a7b8120 | 2025-02-23 09:32:47 +0100 | [diff] [blame] | 452 | call feedkeys(":match NON\<Tab>\<Home>\"\<CR>", 'xt') |
| 453 | call assert_equal('"match NONE', @:) |
Yegappan Lakshmanan | e3846cf | 2022-02-15 11:35:54 +0000 | [diff] [blame] | 454 | call feedkeys(":match | chist\<Tab>\<C-B>\"\<CR>", 'xt') |
| 455 | call assert_equal('"match | chistory', @:) |
Bram Moolenaar | 15eedf1 | 2017-01-22 19:25:33 +0100 | [diff] [blame] | 456 | endfunc |
| 457 | |
| 458 | func Test_highlight_completion() |
Bram Moolenaar | 15eedf1 | 2017-01-22 19:25:33 +0100 | [diff] [blame] | 459 | hi Aardig ctermfg=green |
| 460 | call feedkeys(":hi \<Tab>\<Home>\"\<CR>", 'xt') |
| 461 | call assert_equal('"hi Aardig', getreg(':')) |
Yee Cheng Chin | a7b8120 | 2025-02-23 09:32:47 +0100 | [diff] [blame] | 462 | |
| 463 | " hi default |
Bram Moolenaar | ea58815 | 2017-04-10 22:45:30 +0200 | [diff] [blame] | 464 | call feedkeys(":hi default \<Tab>\<Home>\"\<CR>", 'xt') |
| 465 | call assert_equal('"hi default Aardig', getreg(':')) |
Bram Moolenaar | 15eedf1 | 2017-01-22 19:25:33 +0100 | [diff] [blame] | 466 | call feedkeys(":hi d\<S-Tab>\<Home>\"\<CR>", 'xt') |
| 467 | call assert_equal('"hi default', getreg(':')) |
Yee Cheng Chin | a7b8120 | 2025-02-23 09:32:47 +0100 | [diff] [blame] | 468 | call feedkeys(":hi default link Aa\<Tab>\<Home>\"\<CR>", 'xt') |
| 469 | call assert_equal('"hi default link Aardig', getreg(':')) |
| 470 | |
| 471 | " hi clear only accepts one parameter |
Bram Moolenaar | 15eedf1 | 2017-01-22 19:25:33 +0100 | [diff] [blame] | 472 | call feedkeys(":hi c\<S-Tab>\<Home>\"\<CR>", 'xt') |
| 473 | call assert_equal('"hi clear', getreg(':')) |
Yee Cheng Chin | a7b8120 | 2025-02-23 09:32:47 +0100 | [diff] [blame] | 474 | call feedkeys(":hi clear Aa\<Tab>\<Home>\"\<CR>", 'xt') |
| 475 | call assert_equal('"hi clear Aardig', getreg(':')) |
Bram Moolenaar | 75e1567 | 2020-06-28 13:10:22 +0200 | [diff] [blame] | 476 | call feedkeys(":hi clear Aardig Aard\<Tab>\<C-B>\"\<CR>", 'xt') |
Yee Cheng Chin | a7b8120 | 2025-02-23 09:32:47 +0100 | [diff] [blame] | 477 | call assert_equal("\"hi clear Aardig Aard\<Tab>", getreg(':')) |
| 478 | " hi link accepts up to two parameters |
| 479 | call feedkeys(":hi li\<S-Tab>\<Home>\"\<CR>", 'xt') |
| 480 | call assert_equal('"hi link', getreg(':')) |
| 481 | call assert_equal('"hi link', getreg(':')) |
| 482 | call feedkeys(":hi link Aa\<Tab>\<Home>\"\<CR>", 'xt') |
| 483 | call assert_equal('"hi link Aardig', getreg(':')) |
| 484 | call feedkeys(":hi link Aardig Aard\<Tab>\<C-B>\"\<CR>", 'xt') |
| 485 | call assert_equal("\"hi link Aardig Aardig", getreg(':')) |
| 486 | call feedkeys(":hi link Aardig Aardig Aard\<Tab>\<C-B>\"\<CR>", 'xt') |
| 487 | call assert_equal("\"hi link Aardig Aardig Aard\<Tab>", getreg(':')) |
| 488 | " hi link will complete to "NONE" for second parameter |
| 489 | call feedkeys(":hi link NON\<Tab>\<Home>\"\<CR>", 'xt') |
| 490 | call assert_equal("\"hi link NonText", getreg(':')) |
| 491 | call feedkeys(":hi link Aardig NON\<Tab>\<Home>\"\<CR>", 'xt') |
| 492 | call assert_equal("\"hi link Aardig NONE", getreg(':')) |
Bram Moolenaar | c96272e | 2017-03-26 13:50:09 +0200 | [diff] [blame] | 493 | |
| 494 | " A cleared group does not show up in completions. |
| 495 | hi Anders ctermfg=green |
| 496 | call assert_equal(['Aardig', 'Anders'], getcompletion('A', 'highlight')) |
| 497 | hi clear Aardig |
| 498 | call assert_equal(['Anders'], getcompletion('A', 'highlight')) |
| 499 | hi clear Anders |
| 500 | call assert_equal([], getcompletion('A', 'highlight')) |
Bram Moolenaar | 15eedf1 | 2017-01-22 19:25:33 +0100 | [diff] [blame] | 501 | endfunc |
| 502 | |
Bram Moolenaar | 75e1567 | 2020-06-28 13:10:22 +0200 | [diff] [blame] | 503 | " Test for command-line expansion of "hi Ni " (easter egg) |
| 504 | func Test_highlight_easter_egg() |
| 505 | call test_override('ui_delay', 1) |
| 506 | call feedkeys(":hi Ni \<Tab>\<C-B>\"\<CR>", 'xt') |
| 507 | call assert_equal("\"hi Ni \<Tab>", @:) |
| 508 | call test_override('ALL', 0) |
| 509 | endfunc |
| 510 | |
Yee Cheng Chin | a7b8120 | 2025-02-23 09:32:47 +0100 | [diff] [blame] | 511 | func Test_highlight_group_completion() |
| 512 | " Test completing keys |
| 513 | call assert_equal('term=', getcompletion('hi Foo ', 'cmdline')[0]) |
| 514 | call assert_equal('ctermfg=', getcompletion('hi Foo c*fg', 'cmdline')[0]) |
| 515 | call assert_equal('NONE', getcompletion('hi Foo NON', 'cmdline')[0]) |
| 516 | set wildoptions+=fuzzy |
| 517 | call assert_equal('ctermbg=', getcompletion('hi Foo cmbg', 'cmdline')[0]) |
| 518 | set wildoptions-=fuzzy |
| 519 | |
| 520 | " Test completing the current value |
| 521 | hi FooBar term=bold,underline cterm=undercurl ctermfg=lightgray ctermbg=12 ctermul=34 |
Yee Cheng Chin | 9b41e8f | 2025-02-25 20:41:52 +0100 | [diff] [blame] | 522 | hi AlmostEmpty term=bold |
Yee Cheng Chin | a7b8120 | 2025-02-23 09:32:47 +0100 | [diff] [blame] | 523 | call assert_equal('bold,underline', getcompletion('hi FooBar term=', 'cmdline')[0]) |
| 524 | call assert_equal('undercurl', getcompletion('hi FooBar cterm=', 'cmdline')[0]) |
| 525 | call assert_equal('7', getcompletion('hi FooBar ctermfg=', 'cmdline')[0]) |
| 526 | call assert_equal('12', getcompletion('hi FooBar ctermbg=', 'cmdline')[0]) |
| 527 | call assert_equal('34', getcompletion('hi FooBar ctermul=', 'cmdline')[0]) |
| 528 | |
Yee Cheng Chin | 9b41e8f | 2025-02-25 20:41:52 +0100 | [diff] [blame] | 529 | " highlight group exists, but no value was set. Should not complete to |
| 530 | " existing value |
| 531 | call assert_equal('fg', getcompletion('hi AlmostEmpty ctermfg=', 'cmdline')[0]) |
| 532 | call assert_equal('fg', getcompletion('hi AlmostEmpty ctermbg=', 'cmdline')[0]) |
| 533 | call assert_equal('fg', getcompletion('hi AlmostEmpty ctermul=', 'cmdline')[0]) |
| 534 | call assert_equal('bold', getcompletion('hi AlmostEmpty cterm=', 'cmdline')[0]) |
| 535 | |
| 536 | " "bold,underline" is unique and creates an extra item. "undercurl" isn't |
| 537 | " and should be de-duplicated. |
Yee Cheng Chin | a7b8120 | 2025-02-23 09:32:47 +0100 | [diff] [blame] | 538 | call assert_equal(len(getcompletion('hi FooBar term=', 'cmdline')), |
| 539 | \ 1 + len(getcompletion('hi FooBar cterm=', 'cmdline'))) |
| 540 | |
| 541 | " don't complete original value if we have user input already, similar to |
| 542 | " behavior in :set <option>=<pattern> |
| 543 | call assert_equal(['bold'], getcompletion('hi FooBar term=bol', 'cmdline')) |
| 544 | call assert_equal([], getcompletion('hi FooBar ctermfg=1', 'cmdline')) |
| 545 | |
| 546 | " start/stop do not fill their current value now as they are more |
| 547 | " complicated |
| 548 | hi FooBar start=123 stop=234 |
| 549 | call assert_equal([], getcompletion('hi FooBar start=', 'cmdline')) |
| 550 | call assert_equal([], getcompletion('hi FooBar stop=', 'cmdline')) |
| 551 | |
| 552 | if has("gui") || has("termguicolors") |
| 553 | hi FooBar gui=italic guifg=#112233 guibg=brown1 guisp=green |
| 554 | call assert_equal('italic', getcompletion('hi FooBar gui=', 'cmdline')[0]) |
| 555 | call assert_equal('#112233', getcompletion('hi FooBar guifg=', 'cmdline')[0]) |
| 556 | call assert_equal('brown1', getcompletion('hi FooBar guibg=', 'cmdline')[0]) |
| 557 | call assert_equal('green', getcompletion('hi FooBar guisp=', 'cmdline')[0]) |
| 558 | |
| 559 | " Check that existing value is de-duplicated and doesn't show up later |
| 560 | call assert_equal(1, count(getcompletion('hi FooBar guibg=', 'cmdline'), 'brown1')) |
Yee Cheng Chin | 9b41e8f | 2025-02-25 20:41:52 +0100 | [diff] [blame] | 561 | |
| 562 | " highlight group exists, but no value was set. Should not complete to |
| 563 | " existing value |
| 564 | call assert_equal('fg', getcompletion('hi AlmostEmpty guifg=', 'cmdline')[0]) |
| 565 | call assert_equal('fg', getcompletion('hi AlmostEmpty guibg=', 'cmdline')[0]) |
| 566 | call assert_equal('fg', getcompletion('hi AlmostEmpty guisp=', 'cmdline')[0]) |
| 567 | call assert_equal('bold', getcompletion('hi AlmostEmpty gui=', 'cmdline')[0]) |
Yee Cheng Chin | a7b8120 | 2025-02-23 09:32:47 +0100 | [diff] [blame] | 568 | endif |
| 569 | |
| 570 | " Test completing attributes |
| 571 | call assert_equal(['underdouble', 'underdotted'], getcompletion('hi DoesNotExist term=un*erdo*', 'cmdline')) |
| 572 | call assert_equal('NONE', getcompletion('hi DoesNotExist cterm=NON', 'cmdline')[0]) |
| 573 | call assert_equal('NONE', getcompletion('hi DoesNotExist cterm=', 'cmdline')[-1]) " NONE should be at the end and not sorted |
| 574 | call assert_equal('bold', getcompletion('hi DoesNotExist cterm=underline,bo', 'cmdline')[0]) " complete after comma |
| 575 | if has("gui") || has("termguicolors") |
| 576 | set wildoptions+=fuzzy |
| 577 | call assert_equal('italic', getcompletion('hi DoesNotExist gui=itic', 'cmdline')[0]) |
| 578 | set wildoptions-=fuzzy |
| 579 | endif |
| 580 | |
| 581 | " Test completing cterm colors |
| 582 | call assert_equal('fg', getcompletion('hi FooBar ctermbg=f*g', 'cmdline')[0]) |
| 583 | call assert_equal('fg', getcompletion('hi DoesNotExist ctermbg=f*g', 'cmdline')[0]) |
| 584 | call assert_equal('NONE', getcompletion('hi FooBar ctermfg=NON', 'cmdline')[0]) |
| 585 | call assert_equal('NONE', getcompletion('hi DoesNotExist ctermfg=NON', 'cmdline')[0]) |
| 586 | set wildoptions+=fuzzy |
| 587 | call assert_equal('Black', getcompletion('hi FooBar ctermul=blck', 'cmdline')[0]) |
| 588 | call assert_equal('Black', getcompletion('hi DoesNotExist ctermul=blck', 'cmdline')[0]) |
| 589 | set wildoptions-=fuzzy |
| 590 | |
| 591 | " Test completing gui colors |
| 592 | if has("gui") || has("termguicolors") |
| 593 | call assert_equal('fg', getcompletion('hi FooBar guibg=f*g', 'cmdline')[0]) |
| 594 | call assert_equal('fg', getcompletion('hi DoesNotExist guibg=f*g', 'cmdline')[0]) |
| 595 | call assert_equal('NONE', getcompletion('hi FooBar guifg=NON', 'cmdline')[0]) |
| 596 | call assert_equal('NONE', getcompletion('hi DoesNotExist guifg=NON', 'cmdline')[0]) |
| 597 | set wildoptions=fuzzy |
| 598 | call assert_equal('limegreen', getcompletion('hi FooBar guisp=limgrn', 'cmdline')[0]) |
| 599 | call assert_equal('limegreen', getcompletion('hi DoesNotExist guisp=limgrn', 'cmdline')[0]) |
| 600 | set wildoptions-=fuzzy |
| 601 | |
| 602 | " Test pruning bad color names with space. Vim doesn't support them. |
| 603 | let v:colornames['foobar with space'] = '#123456' |
| 604 | let v:colornames['foobarwithoutspace'] = '#234567' |
| 605 | call assert_equal(['foobarwithoutspace'], getcompletion('hi FooBar guibg=foobarw', 'cmdline')) |
| 606 | |
| 607 | " Test specialized sorting. First few items are special values that |
| 608 | " go first, after that it's a sorted list of color names. |
| 609 | call assert_equal(['fg','bg','NONE'], getcompletion('hi DoesNotExist guifg=', 'cmdline')[0:2]) |
| 610 | let completed_colors=getcompletion('hi DoesNotExist guifg=', 'cmdline')[3:] |
| 611 | let gui_colors_no_space=filter(copy(v:colornames), {key,val -> match(key, ' ')==-1}) |
| 612 | call assert_equal(len(gui_colors_no_space), len(completed_colors)) |
| 613 | call assert_equal(sort(copy(completed_colors)), completed_colors) |
| 614 | |
| 615 | " Test that the specialized sorting still works if we have some pattern matches |
| 616 | let completed_colors=getcompletion('hi DoesNotExist guifg=*blue*', 'cmdline') |
| 617 | call assert_equal(sort(copy(completed_colors)), completed_colors) |
| 618 | call assert_equal('aliceblue', completed_colors[0]) |
| 619 | endif |
| 620 | endfunc |
| 621 | |
Bram Moolenaar | aa4d732 | 2016-07-09 18:50:29 +0200 | [diff] [blame] | 622 | func Test_getcompletion() |
| 623 | let groupcount = len(getcompletion('', 'event')) |
| 624 | call assert_true(groupcount > 0) |
Bram Moolenaar | 4c313b1 | 2019-08-24 22:58:31 +0200 | [diff] [blame] | 625 | let matchcount = len('File'->getcompletion('event')) |
Bram Moolenaar | aa4d732 | 2016-07-09 18:50:29 +0200 | [diff] [blame] | 626 | call assert_true(matchcount > 0) |
| 627 | call assert_true(groupcount > matchcount) |
| 628 | |
Bram Moolenaar | 0d3e24b | 2016-07-09 19:20:59 +0200 | [diff] [blame] | 629 | if has('menu') |
| 630 | source $VIMRUNTIME/menu.vim |
| 631 | let matchcount = len(getcompletion('', 'menu')) |
| 632 | call assert_true(matchcount > 0) |
| 633 | call assert_equal(['File.'], getcompletion('File', 'menu')) |
| 634 | call assert_true(matchcount > 0) |
| 635 | let matchcount = len(getcompletion('File.', 'menu')) |
| 636 | call assert_true(matchcount > 0) |
zeertzjq | 145a6af | 2023-01-22 12:41:55 +0000 | [diff] [blame] | 637 | source $VIMRUNTIME/delmenu.vim |
Bram Moolenaar | 0d3e24b | 2016-07-09 19:20:59 +0200 | [diff] [blame] | 638 | endif |
Bram Moolenaar | aa4d732 | 2016-07-09 18:50:29 +0200 | [diff] [blame] | 639 | |
Bram Moolenaar | c1fb763 | 2016-07-17 23:34:21 +0200 | [diff] [blame] | 640 | let l = getcompletion('v:n', 'var') |
| 641 | call assert_true(index(l, 'v:null') >= 0) |
Bram Moolenaar | b56195e | 2016-07-28 22:53:37 +0200 | [diff] [blame] | 642 | let l = getcompletion('v:notexists', 'var') |
| 643 | call assert_equal([], l) |
Bram Moolenaar | c1fb763 | 2016-07-17 23:34:21 +0200 | [diff] [blame] | 644 | |
Bram Moolenaar | cd43eff | 2018-03-29 15:55:38 +0200 | [diff] [blame] | 645 | args a.c b.c |
| 646 | let l = getcompletion('', 'arglist') |
| 647 | call assert_equal(['a.c', 'b.c'], l) |
Yegappan Lakshmanan | 9773db6 | 2022-02-14 11:10:59 +0000 | [diff] [blame] | 648 | let l = getcompletion('a.', 'buffer') |
| 649 | call assert_equal(['a.c'], l) |
Bram Moolenaar | cd43eff | 2018-03-29 15:55:38 +0200 | [diff] [blame] | 650 | %argdelete |
| 651 | |
Bram Moolenaar | c1fb763 | 2016-07-17 23:34:21 +0200 | [diff] [blame] | 652 | let l = getcompletion('', 'augroup') |
| 653 | call assert_true(index(l, 'END') >= 0) |
Bram Moolenaar | b56195e | 2016-07-28 22:53:37 +0200 | [diff] [blame] | 654 | let l = getcompletion('blahblah', 'augroup') |
| 655 | call assert_equal([], l) |
Bram Moolenaar | c1fb763 | 2016-07-17 23:34:21 +0200 | [diff] [blame] | 656 | |
| 657 | let l = getcompletion('', 'behave') |
| 658 | call assert_true(index(l, 'mswin') >= 0) |
Bram Moolenaar | b56195e | 2016-07-28 22:53:37 +0200 | [diff] [blame] | 659 | let l = getcompletion('not', 'behave') |
| 660 | call assert_equal([], l) |
Bram Moolenaar | c1fb763 | 2016-07-17 23:34:21 +0200 | [diff] [blame] | 661 | |
| 662 | let l = getcompletion('', 'color') |
| 663 | call assert_true(index(l, 'default') >= 0) |
Bram Moolenaar | b56195e | 2016-07-28 22:53:37 +0200 | [diff] [blame] | 664 | let l = getcompletion('dirty', 'color') |
| 665 | call assert_equal([], l) |
Bram Moolenaar | c1fb763 | 2016-07-17 23:34:21 +0200 | [diff] [blame] | 666 | |
| 667 | let l = getcompletion('', 'command') |
| 668 | call assert_true(index(l, 'sleep') >= 0) |
Bram Moolenaar | b56195e | 2016-07-28 22:53:37 +0200 | [diff] [blame] | 669 | let l = getcompletion('awake', 'command') |
| 670 | call assert_equal([], l) |
Bram Moolenaar | c1fb763 | 2016-07-17 23:34:21 +0200 | [diff] [blame] | 671 | |
| 672 | let l = getcompletion('', 'dir') |
Bram Moolenaar | b56195e | 2016-07-28 22:53:37 +0200 | [diff] [blame] | 673 | call assert_true(index(l, 'samples/') >= 0) |
| 674 | let l = getcompletion('NoMatch', 'dir') |
| 675 | call assert_equal([], l) |
Bram Moolenaar | c1fb763 | 2016-07-17 23:34:21 +0200 | [diff] [blame] | 676 | |
Shougo Matsushita | ae38a9d | 2021-10-21 11:39:53 +0100 | [diff] [blame] | 677 | if glob('~/*') !=# '' |
| 678 | let l = getcompletion('~/', 'dir') |
| 679 | call assert_true(l[0][0] ==# '~') |
| 680 | endif |
| 681 | |
Bram Moolenaar | c1fb763 | 2016-07-17 23:34:21 +0200 | [diff] [blame] | 682 | let l = getcompletion('exe', 'expression') |
| 683 | call assert_true(index(l, 'executable(') >= 0) |
Bram Moolenaar | b56195e | 2016-07-28 22:53:37 +0200 | [diff] [blame] | 684 | let l = getcompletion('kill', 'expression') |
| 685 | call assert_equal([], l) |
Bram Moolenaar | c1fb763 | 2016-07-17 23:34:21 +0200 | [diff] [blame] | 686 | |
Christian Brabandt | a3422aa | 2025-04-23 21:04:24 +0200 | [diff] [blame] | 687 | let l = getcompletion('', 'filetypecmd') |
| 688 | call assert_equal(["indent", "off", "on", "plugin"], l) |
| 689 | let l = getcompletion('not', 'filetypecmd') |
| 690 | call assert_equal([], l) |
| 691 | let l = getcompletion('o', 'filetypecmd') |
| 692 | call assert_equal(['off', 'on'], l) |
| 693 | |
Bram Moolenaar | c1fb763 | 2016-07-17 23:34:21 +0200 | [diff] [blame] | 694 | let l = getcompletion('tag', 'function') |
| 695 | call assert_true(index(l, 'taglist(') >= 0) |
Bram Moolenaar | b56195e | 2016-07-28 22:53:37 +0200 | [diff] [blame] | 696 | let l = getcompletion('paint', 'function') |
| 697 | call assert_equal([], l) |
Bram Moolenaar | c1fb763 | 2016-07-17 23:34:21 +0200 | [diff] [blame] | 698 | |
Kota Kato | 90c2353 | 2023-01-18 15:27:38 +0000 | [diff] [blame] | 699 | if !has('ruby') |
Bram Moolenaar | a9a6b03 | 2023-02-05 18:00:42 +0000 | [diff] [blame] | 700 | " global_functions[] has an entry but it doesn't have an implementation |
Kota Kato | 90c2353 | 2023-01-18 15:27:38 +0000 | [diff] [blame] | 701 | let l = getcompletion('ruby', 'function') |
| 702 | call assert_equal([], l) |
| 703 | endif |
| 704 | |
Bram Moolenaar | b49edc1 | 2016-07-23 15:47:34 +0200 | [diff] [blame] | 705 | let Flambda = {-> 'hello'} |
| 706 | let l = getcompletion('', 'function') |
| 707 | let l = filter(l, {i, v -> v =~ 'lambda'}) |
Bram Moolenaar | b56195e | 2016-07-28 22:53:37 +0200 | [diff] [blame] | 708 | call assert_equal([], l) |
Bram Moolenaar | b49edc1 | 2016-07-23 15:47:34 +0200 | [diff] [blame] | 709 | |
Bram Moolenaar | c1fb763 | 2016-07-17 23:34:21 +0200 | [diff] [blame] | 710 | let l = getcompletion('run', 'file') |
| 711 | call assert_true(index(l, 'runtest.vim') >= 0) |
Bram Moolenaar | b56195e | 2016-07-28 22:53:37 +0200 | [diff] [blame] | 712 | let l = getcompletion('walk', 'file') |
| 713 | call assert_equal([], l) |
Bram Moolenaar | e9d58a6 | 2016-08-13 15:07:41 +0200 | [diff] [blame] | 714 | set wildignore=*.vim |
| 715 | let l = getcompletion('run', 'file', 1) |
| 716 | call assert_true(index(l, 'runtest.vim') < 0) |
| 717 | set wildignore& |
Yegappan Lakshmanan | e3846cf | 2022-02-15 11:35:54 +0000 | [diff] [blame] | 718 | " Directory name with space character |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 719 | call mkdir('Xdir with space', 'D') |
Yegappan Lakshmanan | e3846cf | 2022-02-15 11:35:54 +0000 | [diff] [blame] | 720 | call assert_equal(['Xdir with space/'], getcompletion('Xdir\ w', 'shellcmd')) |
| 721 | call assert_equal(['./Xdir with space/'], getcompletion('./Xdir', 'shellcmd')) |
Bram Moolenaar | c1fb763 | 2016-07-17 23:34:21 +0200 | [diff] [blame] | 722 | |
| 723 | let l = getcompletion('ha', 'filetype') |
| 724 | call assert_true(index(l, 'hamster') >= 0) |
Bram Moolenaar | b56195e | 2016-07-28 22:53:37 +0200 | [diff] [blame] | 725 | let l = getcompletion('horse', 'filetype') |
| 726 | call assert_equal([], l) |
Bram Moolenaar | c1fb763 | 2016-07-17 23:34:21 +0200 | [diff] [blame] | 727 | |
Doug Kearns | 81642d9 | 2024-01-04 22:37:44 +0100 | [diff] [blame] | 728 | if has('keymap') |
| 729 | let l = getcompletion('acc', 'keymap') |
| 730 | call assert_true(index(l, 'accents') >= 0) |
| 731 | let l = getcompletion('nullkeymap', 'keymap') |
| 732 | call assert_equal([], l) |
| 733 | endif |
| 734 | |
Bram Moolenaar | c1fb763 | 2016-07-17 23:34:21 +0200 | [diff] [blame] | 735 | let l = getcompletion('z', 'syntax') |
| 736 | call assert_true(index(l, 'zimbu') >= 0) |
Bram Moolenaar | b56195e | 2016-07-28 22:53:37 +0200 | [diff] [blame] | 737 | let l = getcompletion('emacs', 'syntax') |
| 738 | call assert_equal([], l) |
Bram Moolenaar | c1fb763 | 2016-07-17 23:34:21 +0200 | [diff] [blame] | 739 | |
| 740 | let l = getcompletion('jikes', 'compiler') |
| 741 | call assert_true(index(l, 'jikes') >= 0) |
Bram Moolenaar | b56195e | 2016-07-28 22:53:37 +0200 | [diff] [blame] | 742 | let l = getcompletion('break', 'compiler') |
| 743 | call assert_equal([], l) |
Bram Moolenaar | c1fb763 | 2016-07-17 23:34:21 +0200 | [diff] [blame] | 744 | |
| 745 | let l = getcompletion('last', 'help') |
| 746 | call assert_true(index(l, ':tablast') >= 0) |
Bram Moolenaar | b56195e | 2016-07-28 22:53:37 +0200 | [diff] [blame] | 747 | let l = getcompletion('giveup', 'help') |
| 748 | call assert_equal([], l) |
Bram Moolenaar | c1fb763 | 2016-07-17 23:34:21 +0200 | [diff] [blame] | 749 | |
| 750 | let l = getcompletion('time', 'option') |
| 751 | call assert_true(index(l, 'timeoutlen') >= 0) |
Bram Moolenaar | b56195e | 2016-07-28 22:53:37 +0200 | [diff] [blame] | 752 | let l = getcompletion('space', 'option') |
| 753 | call assert_equal([], l) |
Bram Moolenaar | c1fb763 | 2016-07-17 23:34:21 +0200 | [diff] [blame] | 754 | |
| 755 | let l = getcompletion('er', 'highlight') |
| 756 | call assert_true(index(l, 'ErrorMsg') >= 0) |
Bram Moolenaar | b56195e | 2016-07-28 22:53:37 +0200 | [diff] [blame] | 757 | let l = getcompletion('dark', 'highlight') |
| 758 | call assert_equal([], l) |
Bram Moolenaar | c1fb763 | 2016-07-17 23:34:21 +0200 | [diff] [blame] | 759 | |
Bram Moolenaar | 9e507ca | 2016-10-15 15:39:39 +0200 | [diff] [blame] | 760 | let l = getcompletion('', 'messages') |
| 761 | call assert_true(index(l, 'clear') >= 0) |
| 762 | let l = getcompletion('not', 'messages') |
| 763 | call assert_equal([], l) |
| 764 | |
Bram Moolenaar | cae92dc | 2017-08-06 15:22:15 +0200 | [diff] [blame] | 765 | let l = getcompletion('', 'mapclear') |
| 766 | call assert_true(index(l, '<buffer>') >= 0) |
| 767 | let l = getcompletion('not', 'mapclear') |
| 768 | call assert_equal([], l) |
| 769 | |
Bram Moolenaar | 62fe66f | 2018-05-22 16:58:47 +0200 | [diff] [blame] | 770 | let l = getcompletion('.', 'shellcmd') |
Bram Moolenaar | 6ab9e42 | 2018-07-28 19:20:13 +0200 | [diff] [blame] | 771 | call assert_equal(['./', '../'], filter(l, 'v:val =~ "\\./"')) |
Bram Moolenaar | 62fe66f | 2018-05-22 16:58:47 +0200 | [diff] [blame] | 772 | call assert_equal(-1, match(l[2:], '^\.\.\?/$')) |
| 773 | let root = has('win32') ? 'C:\\' : '/' |
| 774 | let l = getcompletion(root, 'shellcmd') |
| 775 | let expected = map(filter(glob(root . '*', 0, 1), |
| 776 | \ 'isdirectory(v:val) || executable(v:val)'), 'isdirectory(v:val) ? v:val . ''/'' : v:val') |
| 777 | call assert_equal(expected, l) |
| 778 | |
Bram Moolenaar | b650b98 | 2016-08-05 20:35:13 +0200 | [diff] [blame] | 779 | if has('cscope') |
| 780 | let l = getcompletion('', 'cscope') |
| 781 | let cmds = ['add', 'find', 'help', 'kill', 'reset', 'show'] |
| 782 | call assert_equal(cmds, l) |
| 783 | " using cmdline completion must not change the result |
| 784 | call feedkeys(":cscope find \<c-d>\<c-c>", 'xt') |
| 785 | let l = getcompletion('', 'cscope') |
| 786 | call assert_equal(cmds, l) |
| 787 | let keys = ['a', 'c', 'd', 'e', 'f', 'g', 'i', 's', 't'] |
| 788 | let l = getcompletion('find ', 'cscope') |
| 789 | call assert_equal(keys, l) |
| 790 | endif |
| 791 | |
Bram Moolenaar | 7522f69 | 2016-08-06 14:12:50 +0200 | [diff] [blame] | 792 | if has('signs') |
| 793 | sign define Testing linehl=Comment |
| 794 | let l = getcompletion('', 'sign') |
| 795 | let cmds = ['define', 'jump', 'list', 'place', 'undefine', 'unplace'] |
| 796 | call assert_equal(cmds, l) |
| 797 | " using cmdline completion must not change the result |
| 798 | call feedkeys(":sign list \<c-d>\<c-c>", 'xt') |
| 799 | let l = getcompletion('', 'sign') |
| 800 | call assert_equal(cmds, l) |
| 801 | let l = getcompletion('list ', 'sign') |
| 802 | call assert_equal(['Testing'], l) |
Yegappan Lakshmanan | 4d03d87 | 2022-02-13 11:45:09 +0000 | [diff] [blame] | 803 | let l = getcompletion('de*', 'sign') |
| 804 | call assert_equal(['define'], l) |
| 805 | let l = getcompletion('p?', 'sign') |
| 806 | call assert_equal(['place'], l) |
| 807 | let l = getcompletion('j.', 'sign') |
| 808 | call assert_equal(['jump'], l) |
Bram Moolenaar | 7522f69 | 2016-08-06 14:12:50 +0200 | [diff] [blame] | 809 | endif |
| 810 | |
Bram Moolenaar | 1f1fd44 | 2020-06-07 18:45:14 +0200 | [diff] [blame] | 811 | " Command line completion tests |
| 812 | let l = getcompletion('cd ', 'cmdline') |
| 813 | call assert_true(index(l, 'samples/') >= 0) |
| 814 | let l = getcompletion('cd NoMatch', 'cmdline') |
| 815 | call assert_equal([], l) |
| 816 | let l = getcompletion('let v:n', 'cmdline') |
| 817 | call assert_true(index(l, 'v:null') >= 0) |
| 818 | let l = getcompletion('let v:notexists', 'cmdline') |
| 819 | call assert_equal([], l) |
| 820 | let l = getcompletion('call tag', 'cmdline') |
| 821 | call assert_true(index(l, 'taglist(') >= 0) |
| 822 | let l = getcompletion('call paint', 'cmdline') |
| 823 | call assert_equal([], l) |
zeertzjq | e4c79d3 | 2023-08-15 22:41:53 +0200 | [diff] [blame] | 824 | let l = getcompletion('autocmd BufEnter * map <bu', 'cmdline') |
| 825 | call assert_equal(['<buffer>'], l) |
Bram Moolenaar | 1f1fd44 | 2020-06-07 18:45:14 +0200 | [diff] [blame] | 826 | |
Shougo Matsushita | ae38a9d | 2021-10-21 11:39:53 +0100 | [diff] [blame] | 827 | func T(a, c, p) |
ii14 | 4785fe0 | 2021-11-21 12:13:56 +0000 | [diff] [blame] | 828 | let g:cmdline_compl_params = [a:a, a:c, a:p] |
Shougo Matsushita | ae38a9d | 2021-10-21 11:39:53 +0100 | [diff] [blame] | 829 | return "oneA\noneB\noneC" |
| 830 | endfunc |
| 831 | command -nargs=1 -complete=custom,T MyCmd |
| 832 | let l = getcompletion('MyCmd ', 'cmdline') |
| 833 | call assert_equal(['oneA', 'oneB', 'oneC'], l) |
ii14 | 4785fe0 | 2021-11-21 12:13:56 +0000 | [diff] [blame] | 834 | call assert_equal(['', 'MyCmd ', 6], g:cmdline_compl_params) |
Shougo Matsushita | ae38a9d | 2021-10-21 11:39:53 +0100 | [diff] [blame] | 835 | |
| 836 | delcommand MyCmd |
| 837 | delfunc T |
ii14 | 4785fe0 | 2021-11-21 12:13:56 +0000 | [diff] [blame] | 838 | unlet g:cmdline_compl_params |
Shougo Matsushita | ae38a9d | 2021-10-21 11:39:53 +0100 | [diff] [blame] | 839 | |
Bram Moolenaar | c1fb763 | 2016-07-17 23:34:21 +0200 | [diff] [blame] | 840 | " For others test if the name is recognized. |
LemonBoy | a20bf69 | 2024-07-11 22:35:53 +0200 | [diff] [blame] | 841 | let names = ['buffer', 'environment', 'file_in_path', 'dir_in_path', 'mapping', 'tag', |
| 842 | \ 'tag_listfiles', 'user'] |
Bram Moolenaar | c1fb763 | 2016-07-17 23:34:21 +0200 | [diff] [blame] | 843 | if has('cmdline_hist') |
| 844 | call add(names, 'history') |
| 845 | endif |
| 846 | if has('gettext') |
| 847 | call add(names, 'locale') |
| 848 | endif |
| 849 | if has('profile') |
| 850 | call add(names, 'syntime') |
| 851 | endif |
Bram Moolenaar | c1fb763 | 2016-07-17 23:34:21 +0200 | [diff] [blame] | 852 | |
| 853 | set tags=Xtags |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 854 | call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//", "word\tfile\tcmd"], 'Xtags', 'D') |
Bram Moolenaar | c1fb763 | 2016-07-17 23:34:21 +0200 | [diff] [blame] | 855 | |
| 856 | for name in names |
| 857 | let matchcount = len(getcompletion('', name)) |
| 858 | call assert_true(matchcount >= 0, 'No matches for ' . name) |
| 859 | endfor |
| 860 | |
Bram Moolenaar | 0331faf | 2019-06-15 18:40:37 +0200 | [diff] [blame] | 861 | set tags& |
Bram Moolenaar | c1fb763 | 2016-07-17 23:34:21 +0200 | [diff] [blame] | 862 | |
Yegappan Lakshmanan | 4d03d87 | 2022-02-13 11:45:09 +0000 | [diff] [blame] | 863 | edit a~b |
| 864 | enew |
| 865 | call assert_equal(['a~b'], getcompletion('a~', 'buffer')) |
| 866 | bw a~b |
| 867 | |
| 868 | if has('unix') |
| 869 | edit Xtest\ |
| 870 | enew |
| 871 | call assert_equal(['Xtest\'], getcompletion('Xtest\', 'buffer')) |
| 872 | bw Xtest\ |
| 873 | endif |
| 874 | |
Christian Brabandt | 0dc0bff | 2024-02-24 14:12:13 +0100 | [diff] [blame] | 875 | call assert_fails("call getcompletion('\\\\@!\\\\@=', 'buffer')", 'E866:') |
Bram Moolenaar | aa4d732 | 2016-07-09 18:50:29 +0200 | [diff] [blame] | 876 | call assert_fails('call getcompletion("", "burp")', 'E475:') |
Yegappan Lakshmanan | 8deb2b3 | 2022-09-02 15:15:27 +0100 | [diff] [blame] | 877 | call assert_fails('call getcompletion("abc", [])', 'E1174:') |
Bram Moolenaar | aa4d732 | 2016-07-09 18:50:29 +0200 | [diff] [blame] | 878 | endfunc |
Bram Moolenaar | 73d4e4c | 2016-08-27 21:55:13 +0200 | [diff] [blame] | 879 | |
Bram Moolenaar | c32949b | 2023-01-04 15:56:51 +0000 | [diff] [blame] | 880 | func Test_multibyte_expression() |
Bram Moolenaar | 2468add | 2023-01-04 18:59:57 +0000 | [diff] [blame] | 881 | " Get a dialog in the GUI |
| 882 | CheckNotGui |
| 883 | |
Bram Moolenaar | c32949b | 2023-01-04 15:56:51 +0000 | [diff] [blame] | 884 | " This was using uninitialized memory. |
| 885 | let lines =<< trim END |
| 886 | set verbose=6 |
| 887 | norm @=ٷ |
| 888 | qall! |
| 889 | END |
| 890 | call writefile(lines, 'XmultiScript', 'D') |
| 891 | call RunVim('', '', '-u NONE -n -e -s -S XmultiScript') |
| 892 | endfunc |
| 893 | |
Yegappan Lakshmanan | e7dd0fa | 2022-03-22 16:06:31 +0000 | [diff] [blame] | 894 | " Test for getcompletion() with "fuzzy" in 'wildoptions' |
| 895 | func Test_getcompletion_wildoptions() |
| 896 | let save_wildoptions = &wildoptions |
| 897 | set wildoptions& |
| 898 | let l = getcompletion('space', 'option') |
| 899 | call assert_equal([], l) |
| 900 | let l = getcompletion('ier', 'command') |
| 901 | call assert_equal([], l) |
| 902 | set wildoptions=fuzzy |
| 903 | let l = getcompletion('space', 'option') |
| 904 | call assert_true(index(l, 'backspace') >= 0) |
| 905 | let l = getcompletion('ier', 'command') |
| 906 | call assert_true(index(l, 'compiler') >= 0) |
| 907 | let &wildoptions = save_wildoptions |
| 908 | endfunc |
| 909 | |
Bram Moolenaar | fe8e9f6 | 2022-03-16 13:09:15 +0000 | [diff] [blame] | 910 | func Test_complete_autoload_error() |
| 911 | let save_rtp = &rtp |
| 912 | let lines =<< trim END |
| 913 | vim9script |
| 914 | export def Complete(..._): string |
| 915 | return 'match' |
| 916 | enddef |
| 917 | echo this will cause an error |
| 918 | END |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 919 | call mkdir('Xdir/autoload', 'pR') |
Bram Moolenaar | fe8e9f6 | 2022-03-16 13:09:15 +0000 | [diff] [blame] | 920 | call writefile(lines, 'Xdir/autoload/script.vim') |
| 921 | exe 'set rtp+=' .. getcwd() .. '/Xdir' |
| 922 | |
| 923 | let lines =<< trim END |
| 924 | vim9script |
| 925 | import autoload 'script.vim' |
| 926 | command -nargs=* -complete=custom,script.Complete Cmd eval 0 + 0 |
| 927 | &wildcharm = char2nr("\<Tab>") |
| 928 | feedkeys(":Cmd \<Tab>", 'xt') |
| 929 | END |
| 930 | call v9.CheckScriptFailure(lines, 'E121: Undefined variable: this') |
| 931 | |
| 932 | let &rtp = save_rtp |
Bram Moolenaar | fe8e9f6 | 2022-03-16 13:09:15 +0000 | [diff] [blame] | 933 | endfunc |
| 934 | |
Bram Moolenaar | 038e09e | 2021-02-06 12:38:51 +0100 | [diff] [blame] | 935 | func Test_fullcommand() |
| 936 | let tests = { |
| 937 | \ '': '', |
| 938 | \ ':': '', |
| 939 | \ ':::': '', |
| 940 | \ ':::5': '', |
| 941 | \ 'not_a_cmd': '', |
| 942 | \ 'Check': '', |
| 943 | \ 'syntax': 'syntax', |
| 944 | \ ':syntax': 'syntax', |
| 945 | \ '::::syntax': 'syntax', |
| 946 | \ 'sy': 'syntax', |
| 947 | \ 'syn': 'syntax', |
| 948 | \ 'synt': 'syntax', |
| 949 | \ ':sy': 'syntax', |
| 950 | \ '::::sy': 'syntax', |
| 951 | \ 'match': 'match', |
| 952 | \ '2match': 'match', |
| 953 | \ '3match': 'match', |
| 954 | \ 'aboveleft': 'aboveleft', |
| 955 | \ 'abo': 'aboveleft', |
Bram Moolenaar | aa53414 | 2022-09-15 21:46:02 +0100 | [diff] [blame] | 956 | \ 'en': 'endif', |
| 957 | \ 'end': 'endif', |
| 958 | \ 'endi': 'endif', |
Bram Moolenaar | 038e09e | 2021-02-06 12:38:51 +0100 | [diff] [blame] | 959 | \ 's': 'substitute', |
| 960 | \ '5s': 'substitute', |
| 961 | \ ':5s': 'substitute', |
| 962 | \ "'<,'>s": 'substitute', |
| 963 | \ ":'<,'>s": 'substitute', |
LemonBoy | cc766a8 | 2022-04-04 15:46:58 +0100 | [diff] [blame] | 964 | \ 'CheckLin': 'CheckLinux', |
| 965 | \ 'CheckLinux': 'CheckLinux', |
Bram Moolenaar | 038e09e | 2021-02-06 12:38:51 +0100 | [diff] [blame] | 966 | \ } |
| 967 | |
| 968 | for [in, want] in items(tests) |
| 969 | call assert_equal(want, fullcommand(in)) |
| 970 | endfor |
Bram Moolenaar | 4c8e8c6 | 2021-05-26 19:49:09 +0200 | [diff] [blame] | 971 | call assert_equal('', fullcommand(test_null_string())) |
Bram Moolenaar | 038e09e | 2021-02-06 12:38:51 +0100 | [diff] [blame] | 972 | |
| 973 | call assert_equal('syntax', 'syn'->fullcommand()) |
Bram Moolenaar | 80c88ea | 2021-09-08 14:29:46 +0200 | [diff] [blame] | 974 | |
| 975 | command -buffer BufferLocalCommand : |
| 976 | command GlobalCommand : |
| 977 | call assert_equal('GlobalCommand', fullcommand('GlobalCom')) |
| 978 | call assert_equal('BufferLocalCommand', fullcommand('BufferL')) |
| 979 | delcommand BufferLocalCommand |
| 980 | delcommand GlobalCommand |
Bram Moolenaar | 038e09e | 2021-02-06 12:38:51 +0100 | [diff] [blame] | 981 | endfunc |
| 982 | |
Bram Moolenaar | 6ab9e42 | 2018-07-28 19:20:13 +0200 | [diff] [blame] | 983 | func Test_shellcmd_completion() |
| 984 | let save_path = $PATH |
| 985 | |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 986 | call mkdir('Xpathdir/Xpathsubdir', 'pR') |
Bram Moolenaar | 6ab9e42 | 2018-07-28 19:20:13 +0200 | [diff] [blame] | 987 | call writefile([''], 'Xpathdir/Xfile.exe') |
| 988 | call setfperm('Xpathdir/Xfile.exe', 'rwx------') |
| 989 | |
| 990 | " Set PATH to example directory without trailing slash. |
| 991 | let $PATH = getcwd() . '/Xpathdir' |
| 992 | |
| 993 | " Test for the ":!<TAB>" case. Previously, this would include subdirs of |
| 994 | " dirs in the PATH, even though they won't be executed. We check that only |
| 995 | " subdirs of the PWD and executables from the PATH are included in the |
| 996 | " suggestions. |
| 997 | let actual = getcompletion('X', 'shellcmd') |
| 998 | let expected = map(filter(glob('*', 0, 1), 'isdirectory(v:val) && v:val[0] == "X"'), 'v:val . "/"') |
| 999 | call insert(expected, 'Xfile.exe') |
| 1000 | call assert_equal(expected, actual) |
| 1001 | |
Bram Moolenaar | 6ab9e42 | 2018-07-28 19:20:13 +0200 | [diff] [blame] | 1002 | let $PATH = save_path |
| 1003 | endfunc |
| 1004 | |
Bram Moolenaar | 73d4e4c | 2016-08-27 21:55:13 +0200 | [diff] [blame] | 1005 | func Test_expand_star_star() |
Bram Moolenaar | bf63011 | 2023-05-19 21:41:02 +0100 | [diff] [blame] | 1006 | call mkdir('a/b/c', 'pR') |
| 1007 | call writefile(['asdfasdf'], 'a/b/c/fileXname') |
| 1008 | call feedkeys(":find a/**/fileXname\<Tab>\<CR>", 'xt') |
| 1009 | call assert_equal('find a/b/c/fileXname', @:) |
Bram Moolenaar | 1773ddf | 2016-08-28 13:38:54 +0200 | [diff] [blame] | 1010 | bwipe! |
Bram Moolenaar | 73d4e4c | 2016-08-27 21:55:13 +0200 | [diff] [blame] | 1011 | endfunc |
Bram Moolenaar | 21efc36 | 2016-12-03 14:05:49 +0100 | [diff] [blame] | 1012 | |
Bram Moolenaar | 59cb041 | 2019-12-18 22:26:31 +0100 | [diff] [blame] | 1013 | func Test_cmdline_paste() |
Bram Moolenaar | 21efc36 | 2016-12-03 14:05:49 +0100 | [diff] [blame] | 1014 | let @a = "def" |
| 1015 | call feedkeys(":abc \<C-R>a ghi\<C-B>\"\<CR>", 'tx') |
| 1016 | call assert_equal('"abc def ghi', @:) |
| 1017 | |
| 1018 | new |
| 1019 | call setline(1, 'asdf.x /tmp/some verylongword a;b-c*d ') |
| 1020 | |
| 1021 | call feedkeys(":aaa \<C-R>\<C-W> bbb\<C-B>\"\<CR>", 'tx') |
| 1022 | call assert_equal('"aaa asdf bbb', @:) |
| 1023 | |
| 1024 | call feedkeys("ft:aaa \<C-R>\<C-F> bbb\<C-B>\"\<CR>", 'tx') |
| 1025 | call assert_equal('"aaa /tmp/some bbb', @:) |
| 1026 | |
Bram Moolenaar | e2c8d83 | 2018-05-01 19:24:03 +0200 | [diff] [blame] | 1027 | call feedkeys(":aaa \<C-R>\<C-L> bbb\<C-B>\"\<CR>", 'tx') |
| 1028 | call assert_equal('"aaa '.getline(1).' bbb', @:) |
| 1029 | |
Bram Moolenaar | 21efc36 | 2016-12-03 14:05:49 +0100 | [diff] [blame] | 1030 | set incsearch |
| 1031 | call feedkeys("fy:aaa veryl\<C-R>\<C-W> bbb\<C-B>\"\<CR>", 'tx') |
| 1032 | call assert_equal('"aaa verylongword bbb', @:) |
| 1033 | |
| 1034 | call feedkeys("f;:aaa \<C-R>\<C-A> bbb\<C-B>\"\<CR>", 'tx') |
| 1035 | call assert_equal('"aaa a;b-c*d bbb', @:) |
Bram Moolenaar | eaaa9bb | 2016-12-09 18:42:20 +0100 | [diff] [blame] | 1036 | |
| 1037 | call feedkeys(":\<C-\>etoupper(getline(1))\<CR>\<C-B>\"\<CR>", 'tx') |
| 1038 | call assert_equal('"ASDF.X /TMP/SOME VERYLONGWORD A;B-C*D ', @:) |
Bram Moolenaar | 21efc36 | 2016-12-03 14:05:49 +0100 | [diff] [blame] | 1039 | bwipe! |
Bram Moolenaar | 72532d3 | 2018-04-07 19:09:09 +0200 | [diff] [blame] | 1040 | |
| 1041 | " Error while typing a command used to cause that it was not executed |
| 1042 | " in the end. |
| 1043 | new |
| 1044 | try |
| 1045 | call feedkeys(":file \<C-R>%Xtestfile\<CR>", 'tx') |
| 1046 | catch /^Vim\%((\a\+)\)\=:E32/ |
| 1047 | " ignore error E32 |
| 1048 | endtry |
| 1049 | call assert_equal("Xtestfile", bufname("%")) |
Bram Moolenaar | 8d588cc | 2020-02-25 21:47:45 +0100 | [diff] [blame] | 1050 | |
Bram Moolenaar | 578fe94 | 2020-02-27 21:32:51 +0100 | [diff] [blame] | 1051 | " Try to paste an invalid register using <C-R> |
| 1052 | call feedkeys(":\"one\<C-R>\<C-X>two\<CR>", 'xt') |
| 1053 | call assert_equal('"onetwo', @:) |
| 1054 | |
Bram Moolenaar | 91ffc8a | 2020-03-02 20:54:22 +0100 | [diff] [blame] | 1055 | " Test for pasting register containing CTRL-H using CTRL-R and CTRL-R CTRL-R |
Bram Moolenaar | 578fe94 | 2020-02-27 21:32:51 +0100 | [diff] [blame] | 1056 | let @a = "xy\<C-H>z" |
| 1057 | call feedkeys(":\"\<C-R>a\<CR>", 'xt') |
| 1058 | call assert_equal('"xz', @:) |
Bram Moolenaar | 91ffc8a | 2020-03-02 20:54:22 +0100 | [diff] [blame] | 1059 | call feedkeys(":\"\<C-R>\<C-R>a\<CR>", 'xt') |
| 1060 | call assert_equal("\"xy\<C-H>z", @:) |
Bram Moolenaar | 578fe94 | 2020-02-27 21:32:51 +0100 | [diff] [blame] | 1061 | call feedkeys(":\"\<C-R>\<C-O>a\<CR>", 'xt') |
| 1062 | call assert_equal("\"xy\<C-H>z", @:) |
| 1063 | |
Bram Moolenaar | 91ffc8a | 2020-03-02 20:54:22 +0100 | [diff] [blame] | 1064 | " Test for pasting register containing CTRL-V using CTRL-R and CTRL-R CTRL-R |
| 1065 | let @a = "xy\<C-V>z" |
| 1066 | call feedkeys(":\"\<C-R>=@a\<CR>\<cr>", 'xt') |
| 1067 | call assert_equal('"xyz', @:) |
| 1068 | call feedkeys(":\"\<C-R>\<C-R>=@a\<CR>\<cr>", 'xt') |
| 1069 | call assert_equal("\"xy\<C-V>z", @:) |
| 1070 | |
Bram Moolenaar | 578fe94 | 2020-02-27 21:32:51 +0100 | [diff] [blame] | 1071 | call assert_beeps('call feedkeys(":\<C-R>=\<C-R>=\<Esc>", "xt")') |
| 1072 | |
Bram Moolenaar | 72532d3 | 2018-04-07 19:09:09 +0200 | [diff] [blame] | 1073 | bwipe! |
Bram Moolenaar | 21efc36 | 2016-12-03 14:05:49 +0100 | [diff] [blame] | 1074 | endfunc |
Bram Moolenaar | eaaa9bb | 2016-12-09 18:42:20 +0100 | [diff] [blame] | 1075 | |
Bram Moolenaar | 59cb041 | 2019-12-18 22:26:31 +0100 | [diff] [blame] | 1076 | func Test_cmdline_remove_char() |
| 1077 | let encoding_save = &encoding |
Bram Moolenaar | eaaa9bb | 2016-12-09 18:42:20 +0100 | [diff] [blame] | 1078 | |
Bram Moolenaar | 59cb041 | 2019-12-18 22:26:31 +0100 | [diff] [blame] | 1079 | for e in ['utf8', 'latin1'] |
| 1080 | exe 'set encoding=' . e |
Bram Moolenaar | eaaa9bb | 2016-12-09 18:42:20 +0100 | [diff] [blame] | 1081 | |
Bram Moolenaar | 59cb041 | 2019-12-18 22:26:31 +0100 | [diff] [blame] | 1082 | call feedkeys(":abc def\<S-Left>\<Del>\<C-B>\"\<CR>", 'tx') |
| 1083 | call assert_equal('"abc ef', @:, e) |
Bram Moolenaar | eaaa9bb | 2016-12-09 18:42:20 +0100 | [diff] [blame] | 1084 | |
Bram Moolenaar | 59cb041 | 2019-12-18 22:26:31 +0100 | [diff] [blame] | 1085 | call feedkeys(":abc def\<S-Left>\<BS>\<C-B>\"\<CR>", 'tx') |
| 1086 | call assert_equal('"abcdef', @:) |
| 1087 | |
| 1088 | call feedkeys(":abc def ghi\<S-Left>\<C-W>\<C-B>\"\<CR>", 'tx') |
| 1089 | call assert_equal('"abc ghi', @:, e) |
| 1090 | |
| 1091 | call feedkeys(":abc def\<S-Left>\<C-U>\<C-B>\"\<CR>", 'tx') |
| 1092 | call assert_equal('"def', @:, e) |
Bram Moolenaar | ef02f16 | 2022-05-07 10:49:10 +0100 | [diff] [blame] | 1093 | |
| 1094 | " This was going before the start in latin1. |
| 1095 | call feedkeys(": \<C-W>\<CR>", 'tx') |
Bram Moolenaar | 59cb041 | 2019-12-18 22:26:31 +0100 | [diff] [blame] | 1096 | endfor |
| 1097 | |
| 1098 | let &encoding = encoding_save |
| 1099 | endfunc |
| 1100 | |
zeertzjq | ff2b79d | 2024-02-26 20:38:36 +0100 | [diff] [blame] | 1101 | func Test_cmdline_del_utf8() |
| 1102 | let @s = '⒌' |
| 1103 | call feedkeys(":\"\<C-R>s,,\<C-B>\<Right>\<Del>\<CR>", 'tx') |
| 1104 | call assert_equal('",,', @:) |
| 1105 | |
| 1106 | let @s = 'a̳' |
| 1107 | call feedkeys(":\"\<C-R>s,,\<C-B>\<Right>\<Del>\<CR>", 'tx') |
| 1108 | call assert_equal('",,', @:) |
| 1109 | |
| 1110 | let @s = 'β̳' |
| 1111 | call feedkeys(":\"\<C-R>s,,\<C-B>\<Right>\<Del>\<CR>", 'tx') |
| 1112 | call assert_equal('",,', @:) |
| 1113 | |
| 1114 | if has('arabic') |
| 1115 | let @s = 'لا' |
| 1116 | call feedkeys(":\"\<C-R>s,,\<C-B>\<Right>\<Del>\<CR>", 'tx') |
| 1117 | call assert_equal('",,', @:) |
| 1118 | endif |
| 1119 | endfunc |
| 1120 | |
Bram Moolenaar | 59cb041 | 2019-12-18 22:26:31 +0100 | [diff] [blame] | 1121 | func Test_cmdline_keymap_ctrl_hat() |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 1122 | CheckFeature keymap |
Bram Moolenaar | 59cb041 | 2019-12-18 22:26:31 +0100 | [diff] [blame] | 1123 | |
| 1124 | set keymap=esperanto |
| 1125 | call feedkeys(":\"Jxauxdo \<C-^>Jxauxdo \<C-^>Jxauxdo\<CR>", 'tx') |
| 1126 | call assert_equal('"Jxauxdo Ĵaŭdo Jxauxdo', @:) |
| 1127 | set keymap= |
Bram Moolenaar | eaaa9bb | 2016-12-09 18:42:20 +0100 | [diff] [blame] | 1128 | endfunc |
Bram Moolenaar | fe38b49 | 2016-12-11 21:34:23 +0100 | [diff] [blame] | 1129 | |
Bram Moolenaar | f1f6f3f | 2017-02-09 22:28:20 +0100 | [diff] [blame] | 1130 | func Test_illegal_address1() |
Bram Moolenaar | fe38b49 | 2016-12-11 21:34:23 +0100 | [diff] [blame] | 1131 | new |
| 1132 | 2;'( |
| 1133 | 2;') |
| 1134 | quit |
| 1135 | endfunc |
Bram Moolenaar | ba47b51 | 2017-01-24 21:18:19 +0100 | [diff] [blame] | 1136 | |
Bram Moolenaar | f1f6f3f | 2017-02-09 22:28:20 +0100 | [diff] [blame] | 1137 | func Test_illegal_address2() |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 1138 | call writefile(['c', 'x', ' x', '.', '1;y'], 'Xtest.vim', 'D') |
Bram Moolenaar | f1f6f3f | 2017-02-09 22:28:20 +0100 | [diff] [blame] | 1139 | new |
| 1140 | source Xtest.vim |
| 1141 | " Trigger calling validate_cursor() |
| 1142 | diffsp Xtest.vim |
| 1143 | quit! |
| 1144 | bwipe! |
Bram Moolenaar | f1f6f3f | 2017-02-09 22:28:20 +0100 | [diff] [blame] | 1145 | endfunc |
| 1146 | |
Bram Moolenaar | f7c7c3f | 2022-06-22 19:08:38 +0100 | [diff] [blame] | 1147 | func Test_mark_from_line_zero() |
| 1148 | " this was reading past the end of the first (empty) line |
| 1149 | new |
| 1150 | norm oxxxx |
| 1151 | call assert_fails("0;'(", 'E20:') |
| 1152 | bwipe! |
| 1153 | endfunc |
| 1154 | |
Bram Moolenaar | ba47b51 | 2017-01-24 21:18:19 +0100 | [diff] [blame] | 1155 | func Test_cmdline_complete_wildoptions() |
| 1156 | help |
| 1157 | call feedkeys(":tag /\<c-a>\<c-b>\"\<cr>", 'tx') |
| 1158 | let a = join(sort(split(@:)),' ') |
| 1159 | set wildoptions=tagfile |
| 1160 | call feedkeys(":tag /\<c-a>\<c-b>\"\<cr>", 'tx') |
| 1161 | let b = join(sort(split(@:)),' ') |
| 1162 | call assert_equal(a, b) |
| 1163 | bw! |
| 1164 | endfunc |
Bram Moolenaar | cbf20fb | 2017-02-03 21:19:04 +0100 | [diff] [blame] | 1165 | |
Bram Moolenaar | a33ddbb | 2017-03-29 21:30:04 +0200 | [diff] [blame] | 1166 | func Test_cmdline_complete_user_cmd() |
| 1167 | command! -complete=color -nargs=1 Foo : |
| 1168 | call feedkeys(":Foo \<Tab>\<Home>\"\<cr>", 'tx') |
| 1169 | call assert_equal('"Foo blue', @:) |
| 1170 | call feedkeys(":Foo b\<Tab>\<Home>\"\<cr>", 'tx') |
| 1171 | call assert_equal('"Foo blue', @:) |
Yegappan Lakshmanan | e3846cf | 2022-02-15 11:35:54 +0000 | [diff] [blame] | 1172 | call feedkeys(":Foo a b\<Tab>\<Home>\"\<cr>", 'tx') |
| 1173 | call assert_equal('"Foo a blue', @:) |
| 1174 | call feedkeys(":Foo b\\\<Tab>\<Home>\"\<cr>", 'tx') |
| 1175 | call assert_equal('"Foo b\', @:) |
| 1176 | call feedkeys(":Foo b\\x\<Tab>\<Home>\"\<cr>", 'tx') |
| 1177 | call assert_equal('"Foo b\x', @:) |
Bram Moolenaar | a33ddbb | 2017-03-29 21:30:04 +0200 | [diff] [blame] | 1178 | delcommand Foo |
Bram Moolenaar | 300175f | 2022-08-21 18:38:21 +0100 | [diff] [blame] | 1179 | |
| 1180 | redraw |
| 1181 | call assert_equal('~', Screenline(&lines - 1)) |
| 1182 | command! FooOne : |
| 1183 | command! FooTwo : |
| 1184 | |
| 1185 | set nowildmenu |
| 1186 | call feedkeys(":Foo\<Tab>\<Home>\"\<cr>", 'tx') |
| 1187 | call assert_equal('"FooOne', @:) |
| 1188 | call assert_equal('~', Screenline(&lines - 1)) |
| 1189 | |
| 1190 | call feedkeys(":Foo\<S-Tab>\<Home>\"\<cr>", 'tx') |
| 1191 | call assert_equal('"FooTwo', @:) |
| 1192 | call assert_equal('~', Screenline(&lines - 1)) |
| 1193 | |
| 1194 | delcommand FooOne |
| 1195 | delcommand FooTwo |
| 1196 | set wildmenu& |
Bram Moolenaar | a33ddbb | 2017-03-29 21:30:04 +0200 | [diff] [blame] | 1197 | endfunc |
| 1198 | |
Bram Moolenaar | c2842ad | 2022-07-26 17:23:47 +0100 | [diff] [blame] | 1199 | func Test_complete_user_cmd() |
| 1200 | command FooBar echo 'global' |
| 1201 | command -buffer FooBar echo 'local' |
| 1202 | call feedkeys(":Foo\<C-A>\<Home>\"\<CR>", 'tx') |
| 1203 | call assert_equal('"FooBar', @:) |
| 1204 | |
| 1205 | delcommand -buffer FooBar |
| 1206 | delcommand FooBar |
| 1207 | endfunc |
| 1208 | |
Bram Moolenaar | cc390ff | 2020-02-29 22:06:30 +0100 | [diff] [blame] | 1209 | func s:ScriptLocalFunction() |
| 1210 | echo 'yes' |
| 1211 | endfunc |
| 1212 | |
| 1213 | func Test_cmdline_complete_user_func() |
| 1214 | call feedkeys(":func Test_cmdline_complete_user\<Tab>\<Home>\"\<cr>", 'tx') |
naohiro ono | 5aec755 | 2021-08-19 21:20:41 +0200 | [diff] [blame] | 1215 | call assert_match('"func Test_cmdline_complete_user_', @:) |
Bram Moolenaar | cc390ff | 2020-02-29 22:06:30 +0100 | [diff] [blame] | 1216 | call feedkeys(":func s:ScriptL\<Tab>\<Home>\"\<cr>", 'tx') |
| 1217 | call assert_match('"func <SNR>\d\+_ScriptLocalFunction', @:) |
Bram Moolenaar | 1bb4de5 | 2021-01-13 19:48:46 +0100 | [diff] [blame] | 1218 | |
| 1219 | " g: prefix also works |
| 1220 | call feedkeys(":echo g:Test_cmdline_complete_user_f\<Tab>\<Home>\"\<cr>", 'tx') |
| 1221 | call assert_match('"echo g:Test_cmdline_complete_user_func', @:) |
Bram Moolenaar | 069f908 | 2021-08-13 17:48:25 +0200 | [diff] [blame] | 1222 | |
| 1223 | " using g: prefix does not result in just "g:" matches from a lambda |
| 1224 | let Fx = { a -> a } |
| 1225 | call feedkeys(":echo g:\<Tab>\<Home>\"\<cr>", 'tx') |
| 1226 | call assert_match('"echo g:[A-Z]', @:) |
naohiro ono | 5aec755 | 2021-08-19 21:20:41 +0200 | [diff] [blame] | 1227 | |
| 1228 | " existence of script-local dict function does not break user function name |
| 1229 | " completion |
| 1230 | function s:a_dict_func() dict |
| 1231 | endfunction |
| 1232 | call feedkeys(":call Test_cmdline_complete_user\<Tab>\<Home>\"\<cr>", 'tx') |
| 1233 | call assert_match('"call Test_cmdline_complete_user_', @:) |
| 1234 | delfunction s:a_dict_func |
Bram Moolenaar | cc390ff | 2020-02-29 22:06:30 +0100 | [diff] [blame] | 1235 | endfunc |
| 1236 | |
Bram Moolenaar | 5f8f2d3 | 2018-06-19 19:09:09 +0200 | [diff] [blame] | 1237 | func Test_cmdline_complete_user_names() |
| 1238 | if has('unix') && executable('whoami') |
| 1239 | let whoami = systemlist('whoami')[0] |
| 1240 | let first_letter = whoami[0] |
| 1241 | if len(first_letter) > 0 |
| 1242 | " Trying completion of :e ~x where x is the first letter of |
| 1243 | " the user name should complete to at least the user name. |
| 1244 | call feedkeys(':e ~' . first_letter . "\<c-a>\<c-B>\"\<cr>", 'tx') |
| 1245 | call assert_match('^"e \~.*\<' . whoami . '\>', @:) |
| 1246 | endif |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 1247 | elseif has('win32') |
Bram Moolenaar | 5f8f2d3 | 2018-06-19 19:09:09 +0200 | [diff] [blame] | 1248 | " Just in case: check that the system has an Administrator account. |
| 1249 | let names = system('net user') |
| 1250 | if names =~ 'Administrator' |
| 1251 | " Trying completion of :e ~A should complete to Administrator. |
Bram Moolenaar | 346d2a3 | 2019-01-27 20:43:41 +0100 | [diff] [blame] | 1252 | " There could be other names starting with "A" before Administrator. |
Bram Moolenaar | 5f8f2d3 | 2018-06-19 19:09:09 +0200 | [diff] [blame] | 1253 | call feedkeys(':e ~A' . "\<c-a>\<c-B>\"\<cr>", 'tx') |
Bram Moolenaar | 346d2a3 | 2019-01-27 20:43:41 +0100 | [diff] [blame] | 1254 | call assert_match('^"e \~.*Administrator', @:) |
Bram Moolenaar | 5f8f2d3 | 2018-06-19 19:09:09 +0200 | [diff] [blame] | 1255 | endif |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 1256 | else |
| 1257 | throw 'Skipped: does not work on this platform' |
Bram Moolenaar | 5f8f2d3 | 2018-06-19 19:09:09 +0200 | [diff] [blame] | 1258 | endif |
| 1259 | endfunc |
| 1260 | |
Ruslan Russkikh | 0407d62 | 2024-10-08 22:21:05 +0200 | [diff] [blame] | 1261 | func Test_cmdline_complete_shellcmdline() |
| 1262 | CheckExecutable whoami |
| 1263 | command -nargs=1 -complete=shellcmdline MyCmd |
| 1264 | |
| 1265 | call feedkeys(":MyCmd whoam\<C-A>\<C-B>\"\<CR>", 'tx') |
| 1266 | call assert_match('^".*\<whoami\>', @:) |
zeertzjq | 85f36d6 | 2024-10-10 19:14:13 +0200 | [diff] [blame] | 1267 | let l = getcompletion('whoam', 'shellcmdline') |
| 1268 | call assert_match('\<whoami\>', join(l, ' ')) |
Ruslan Russkikh | 0407d62 | 2024-10-08 22:21:05 +0200 | [diff] [blame] | 1269 | |
| 1270 | delcommand MyCmd |
| 1271 | endfunc |
| 1272 | |
Bram Moolenaar | 297610b | 2019-12-27 17:20:55 +0100 | [diff] [blame] | 1273 | func Test_cmdline_complete_bang() |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 1274 | CheckExecutable whoami |
| 1275 | call feedkeys(":!whoam\<C-A>\<C-B>\"\<CR>", 'tx') |
| 1276 | call assert_match('^".*\<whoami\>', @:) |
Bram Moolenaar | 297610b | 2019-12-27 17:20:55 +0100 | [diff] [blame] | 1277 | endfunc |
| 1278 | |
Bram Moolenaar | 8b63313 | 2020-03-20 18:20:51 +0100 | [diff] [blame] | 1279 | func Test_cmdline_complete_languages() |
Bram Moolenaar | 84cf6bd | 2020-06-16 20:03:43 +0200 | [diff] [blame] | 1280 | let lang = substitute(execute('language time'), '.*"\(.*\)"$', '\1', '') |
| 1281 | call assert_equal(lang, v:lc_time) |
| 1282 | |
| 1283 | let lang = substitute(execute('language ctype'), '.*"\(.*\)"$', '\1', '') |
| 1284 | call assert_equal(lang, v:ctype) |
| 1285 | |
| 1286 | let lang = substitute(execute('language collate'), '.*"\(.*\)"$', '\1', '') |
| 1287 | call assert_equal(lang, v:collate) |
| 1288 | |
Bram Moolenaar | 5f8f2d3 | 2018-06-19 19:09:09 +0200 | [diff] [blame] | 1289 | let lang = substitute(execute('language messages'), '.*"\(.*\)"$', '\1', '') |
Bram Moolenaar | 84cf6bd | 2020-06-16 20:03:43 +0200 | [diff] [blame] | 1290 | call assert_equal(lang, v:lang) |
Bram Moolenaar | 5f8f2d3 | 2018-06-19 19:09:09 +0200 | [diff] [blame] | 1291 | |
| 1292 | call feedkeys(":language \<c-a>\<c-b>\"\<cr>", 'tx') |
Bram Moolenaar | 84cf6bd | 2020-06-16 20:03:43 +0200 | [diff] [blame] | 1293 | call assert_match('^"language .*\<collate\>.*\<ctype\>.*\<messages\>.*\<time\>', @:) |
Bram Moolenaar | 5f8f2d3 | 2018-06-19 19:09:09 +0200 | [diff] [blame] | 1294 | |
Bram Moolenaar | ec68028 | 2020-06-12 19:35:32 +0200 | [diff] [blame] | 1295 | call assert_match('^"language .*\<' . lang . '\>', @:) |
Bram Moolenaar | 5f8f2d3 | 2018-06-19 19:09:09 +0200 | [diff] [blame] | 1296 | |
Bram Moolenaar | ec68028 | 2020-06-12 19:35:32 +0200 | [diff] [blame] | 1297 | call feedkeys(":language messages \<c-a>\<c-b>\"\<cr>", 'tx') |
| 1298 | call assert_match('^"language .*\<' . lang . '\>', @:) |
Bram Moolenaar | 5f8f2d3 | 2018-06-19 19:09:09 +0200 | [diff] [blame] | 1299 | |
Bram Moolenaar | ec68028 | 2020-06-12 19:35:32 +0200 | [diff] [blame] | 1300 | call feedkeys(":language ctype \<c-a>\<c-b>\"\<cr>", 'tx') |
| 1301 | call assert_match('^"language .*\<' . lang . '\>', @:) |
Bram Moolenaar | 5f8f2d3 | 2018-06-19 19:09:09 +0200 | [diff] [blame] | 1302 | |
Bram Moolenaar | ec68028 | 2020-06-12 19:35:32 +0200 | [diff] [blame] | 1303 | call feedkeys(":language time \<c-a>\<c-b>\"\<cr>", 'tx') |
| 1304 | call assert_match('^"language .*\<' . lang . '\>', @:) |
Bram Moolenaar | 84cf6bd | 2020-06-16 20:03:43 +0200 | [diff] [blame] | 1305 | |
| 1306 | call feedkeys(":language collate \<c-a>\<c-b>\"\<cr>", 'tx') |
| 1307 | call assert_match('^"language .*\<' . lang . '\>', @:) |
Bram Moolenaar | 5f8f2d3 | 2018-06-19 19:09:09 +0200 | [diff] [blame] | 1308 | endfunc |
| 1309 | |
Bram Moolenaar | 297610b | 2019-12-27 17:20:55 +0100 | [diff] [blame] | 1310 | func Test_cmdline_complete_env_variable() |
| 1311 | let $X_VIM_TEST_COMPLETE_ENV = 'foo' |
Bram Moolenaar | 297610b | 2019-12-27 17:20:55 +0100 | [diff] [blame] | 1312 | call feedkeys(":edit $X_VIM_TEST_COMPLETE_E\<C-A>\<C-B>\"\<CR>", 'tx') |
| 1313 | call assert_match('"edit $X_VIM_TEST_COMPLETE_ENV', @:) |
Bram Moolenaar | 297610b | 2019-12-27 17:20:55 +0100 | [diff] [blame] | 1314 | unlet $X_VIM_TEST_COMPLETE_ENV |
| 1315 | endfunc |
| 1316 | |
Bram Moolenaar | 4941b5e | 2020-12-24 17:15:53 +0100 | [diff] [blame] | 1317 | func Test_cmdline_complete_expression() |
| 1318 | let g:SomeVar = 'blah' |
| 1319 | for cmd in ['exe', 'echo', 'echon', 'echomsg'] |
| 1320 | call feedkeys(":" .. cmd .. " SomeV\<Tab>\<C-B>\"\<CR>", 'tx') |
| 1321 | call assert_match('"' .. cmd .. ' SomeVar', @:) |
| 1322 | call feedkeys(":" .. cmd .. " foo SomeV\<Tab>\<C-B>\"\<CR>", 'tx') |
| 1323 | call assert_match('"' .. cmd .. ' foo SomeVar', @:) |
| 1324 | endfor |
| 1325 | unlet g:SomeVar |
| 1326 | endfunc |
| 1327 | |
Yee Cheng Chin | 989426b | 2023-10-14 11:46:51 +0200 | [diff] [blame] | 1328 | func Test_cmdline_complete_argopt() |
| 1329 | " completion for ++opt=arg for file commands |
| 1330 | call assert_equal('fileformat=', getcompletion('edit ++', 'cmdline')[0]) |
| 1331 | call assert_equal('encoding=', getcompletion('read ++e', 'cmdline')[0]) |
| 1332 | call assert_equal('edit', getcompletion('read ++bin ++edi', 'cmdline')[0]) |
| 1333 | |
| 1334 | call assert_equal(['fileformat='], getcompletion('edit ++ff', 'cmdline')) |
Yee Cheng Chin | 209ec90 | 2023-10-17 10:56:25 +0200 | [diff] [blame] | 1335 | " Test ++ff in the middle of the cmdline |
| 1336 | call feedkeys(":edit ++ff zz\<Left>\<Left>\<Left>\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1337 | call assert_equal("\"edit ++fileformat= zz", @:) |
Yee Cheng Chin | 989426b | 2023-10-14 11:46:51 +0200 | [diff] [blame] | 1338 | |
| 1339 | call assert_equal('dos', getcompletion('write ++ff=d', 'cmdline')[0]) |
| 1340 | call assert_equal('mac', getcompletion('args ++fileformat=m', 'cmdline')[0]) |
| 1341 | call assert_equal('utf-8', getcompletion('split ++enc=ut*-8', 'cmdline')[0]) |
| 1342 | call assert_equal('latin1', getcompletion('tabedit ++encoding=lati', 'cmdline')[0]) |
| 1343 | call assert_equal('keep', getcompletion('edit ++bad=k', 'cmdline')[0]) |
| 1344 | |
| 1345 | call assert_equal([], getcompletion('edit ++bogus=', 'cmdline')) |
| 1346 | |
| 1347 | " completion should skip the ++opt and continue |
| 1348 | call writefile([], 'Xaaaaa.txt', 'D') |
| 1349 | call feedkeys(":split ++enc=latin1 Xaaa\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1350 | call assert_equal('"split ++enc=latin1 Xaaaaa.txt', @:) |
| 1351 | |
| 1352 | if has('terminal') |
| 1353 | " completion for terminal's [options] |
| 1354 | call assert_equal('close', getcompletion('terminal ++cl*e', 'cmdline')[0]) |
| 1355 | call assert_equal('hidden', getcompletion('terminal ++open ++hidd', 'cmdline')[0]) |
| 1356 | call assert_equal('term', getcompletion('terminal ++kill=ter', 'cmdline')[0]) |
| 1357 | |
| 1358 | call assert_equal([], getcompletion('terminal ++bogus=', 'cmdline')) |
| 1359 | |
| 1360 | " :terminal completion should skip the ++opt when considering what is the |
| 1361 | " first option, which is a list of shell commands, unlike second option |
| 1362 | " onwards. |
| 1363 | let first_param = getcompletion('terminal ', 'cmdline') |
| 1364 | let second_param = getcompletion('terminal foo ', 'cmdline') |
| 1365 | let skipped_opt_param = getcompletion('terminal ++close ', 'cmdline') |
| 1366 | call assert_equal(first_param, skipped_opt_param) |
| 1367 | call assert_notequal(first_param, second_param) |
| 1368 | endif |
| 1369 | endfunc |
| 1370 | |
Bram Moolenaar | 47016f5 | 2021-08-26 16:39:58 +0200 | [diff] [blame] | 1371 | " Unique function name for completion below |
| 1372 | func s:WeirdFunc() |
| 1373 | echo 'weird' |
| 1374 | endfunc |
| 1375 | |
Bram Moolenaar | 24ebd83 | 2020-03-16 21:25:24 +0100 | [diff] [blame] | 1376 | " Test for various command-line completion |
| 1377 | func Test_cmdline_complete_various() |
| 1378 | " completion for a command starting with a comment |
| 1379 | call feedkeys(": :|\"\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1380 | call assert_equal("\" :|\"\<C-A>", @:) |
| 1381 | |
| 1382 | " completion for a range followed by a comment |
| 1383 | call feedkeys(":1,2\"\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1384 | call assert_equal("\"1,2\"\<C-A>", @:) |
| 1385 | |
| 1386 | " completion for :k command |
| 1387 | call feedkeys(":ka\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1388 | call assert_equal("\"ka\<C-A>", @:) |
| 1389 | |
Doug Kearns | ea84202 | 2024-09-29 17:17:41 +0200 | [diff] [blame] | 1390 | " completion for :keepmarks command |
| 1391 | call feedkeys(":kee edi\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1392 | call assert_equal("\"kee edit", @:) |
| 1393 | |
Bram Moolenaar | 24ebd83 | 2020-03-16 21:25:24 +0100 | [diff] [blame] | 1394 | " completion for short version of the :s command |
| 1395 | call feedkeys(":sI \<C-A>\<C-B>\"\<CR>", 'xt') |
| 1396 | call assert_equal("\"sI \<C-A>", @:) |
| 1397 | |
| 1398 | " completion for :write command |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 1399 | call mkdir('Xcwdir', 'R') |
Bram Moolenaar | 61abe7d | 2022-08-30 21:46:08 +0100 | [diff] [blame] | 1400 | call writefile(['one'], 'Xcwdir/Xfile1') |
Bram Moolenaar | 24ebd83 | 2020-03-16 21:25:24 +0100 | [diff] [blame] | 1401 | let save_cwd = getcwd() |
Bram Moolenaar | 61abe7d | 2022-08-30 21:46:08 +0100 | [diff] [blame] | 1402 | cd Xcwdir |
Bram Moolenaar | 24ebd83 | 2020-03-16 21:25:24 +0100 | [diff] [blame] | 1403 | call feedkeys(":w >> \<C-A>\<C-B>\"\<CR>", 'xt') |
| 1404 | call assert_equal("\"w >> Xfile1", @:) |
| 1405 | call chdir(save_cwd) |
Bram Moolenaar | 24ebd83 | 2020-03-16 21:25:24 +0100 | [diff] [blame] | 1406 | |
| 1407 | " completion for :w ! and :r ! commands |
| 1408 | call feedkeys(":w !invalid_xyz_cmd\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1409 | call assert_equal("\"w !invalid_xyz_cmd", @:) |
| 1410 | call feedkeys(":r !invalid_xyz_cmd\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1411 | call assert_equal("\"r !invalid_xyz_cmd", @:) |
| 1412 | |
| 1413 | " completion for :>> and :<< commands |
| 1414 | call feedkeys(":>>>\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1415 | call assert_equal("\">>>\<C-A>", @:) |
| 1416 | call feedkeys(":<<<\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1417 | call assert_equal("\"<<<\<C-A>", @:) |
| 1418 | |
| 1419 | " completion for command with +cmd argument |
| 1420 | call feedkeys(":buffer +/pat Xabc\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1421 | call assert_equal("\"buffer +/pat Xabc", @:) |
| 1422 | call feedkeys(":buffer +/pat\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1423 | call assert_equal("\"buffer +/pat\<C-A>", @:) |
| 1424 | |
| 1425 | " completion for a command with a trailing comment |
| 1426 | call feedkeys(":ls \" comment\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1427 | call assert_equal("\"ls \" comment\<C-A>", @:) |
| 1428 | |
| 1429 | " completion for a command with a trailing command |
| 1430 | call feedkeys(":ls | ls\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1431 | call assert_equal("\"ls | ls", @:) |
| 1432 | |
| 1433 | " completion for a command with an CTRL-V escaped argument |
| 1434 | call feedkeys(":ls \<C-V>\<C-V>a\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1435 | call assert_equal("\"ls \<C-V>a\<C-A>", @:) |
| 1436 | |
| 1437 | " completion for a command that doesn't take additional arguments |
| 1438 | call feedkeys(":all abc\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1439 | call assert_equal("\"all abc\<C-A>", @:) |
| 1440 | |
zeertzjq | d3de178 | 2022-09-01 12:58:52 +0100 | [diff] [blame] | 1441 | " completion for :wincmd with :horizontal modifier |
| 1442 | call feedkeys(":horizontal wincm\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1443 | call assert_equal("\"horizontal wincmd", @:) |
| 1444 | |
Bram Moolenaar | 24ebd83 | 2020-03-16 21:25:24 +0100 | [diff] [blame] | 1445 | " completion for a command with a command modifier |
| 1446 | call feedkeys(":topleft new\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1447 | call assert_equal("\"topleft new", @:) |
| 1448 | |
Bram Moolenaar | e70e12b | 2021-06-13 17:20:08 +0200 | [diff] [blame] | 1449 | " completion for vim9 and legacy commands |
| 1450 | call feedkeys(":vim9 call strle\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1451 | call assert_equal("\"vim9 call strlen(", @:) |
| 1452 | call feedkeys(":legac call strle\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1453 | call assert_equal("\"legac call strlen(", @:) |
| 1454 | |
Bram Moolenaar | 4ee9d8e | 2021-06-13 18:38:48 +0200 | [diff] [blame] | 1455 | " completion for the :disassemble command |
| 1456 | call feedkeys(":disas deb\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1457 | call assert_equal("\"disas debug", @:) |
| 1458 | call feedkeys(":disas pro\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1459 | call assert_equal("\"disas profile", @:) |
| 1460 | call feedkeys(":disas debug Test_cmdline_complete_var\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1461 | call assert_equal("\"disas debug Test_cmdline_complete_various", @:) |
| 1462 | call feedkeys(":disas profile Test_cmdline_complete_var\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1463 | call assert_equal("\"disas profile Test_cmdline_complete_various", @:) |
naohiro ono | 9aecf79 | 2021-08-28 15:56:06 +0200 | [diff] [blame] | 1464 | call feedkeys(":disas Test_cmdline_complete_var\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1465 | call assert_equal("\"disas Test_cmdline_complete_various", @:) |
Bram Moolenaar | 4ee9d8e | 2021-06-13 18:38:48 +0200 | [diff] [blame] | 1466 | |
Bram Moolenaar | 47016f5 | 2021-08-26 16:39:58 +0200 | [diff] [blame] | 1467 | call feedkeys(":disas s:WeirdF\<C-A>\<C-B>\"\<CR>", 'xt') |
naohiro ono | 9aecf79 | 2021-08-28 15:56:06 +0200 | [diff] [blame] | 1468 | call assert_match('"disas <SNR>\d\+_WeirdFunc', @:) |
Bram Moolenaar | 47016f5 | 2021-08-26 16:39:58 +0200 | [diff] [blame] | 1469 | |
naohiro ono | dfe04db | 2021-09-12 15:45:10 +0200 | [diff] [blame] | 1470 | call feedkeys(":disas \<S-Tab>\<C-B>\"\<CR>", 'xt') |
| 1471 | call assert_match('"disas <SNR>\d\+_', @:) |
| 1472 | call feedkeys(":disas debug \<S-Tab>\<C-B>\"\<CR>", 'xt') |
| 1473 | call assert_match('"disas debug <SNR>\d\+_', @:) |
| 1474 | |
Bram Moolenaar | 24ebd83 | 2020-03-16 21:25:24 +0100 | [diff] [blame] | 1475 | " completion for the :match command |
| 1476 | call feedkeys(":match Search /pat/\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1477 | call assert_equal("\"match Search /pat/\<C-A>", @:) |
| 1478 | |
Bram Moolenaar | 24ebd83 | 2020-03-16 21:25:24 +0100 | [diff] [blame] | 1479 | " completion for the :doautocmd command |
| 1480 | call feedkeys(":doautocmd User MyCmd a.c\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1481 | call assert_equal("\"doautocmd User MyCmd a.c\<C-A>", @:) |
| 1482 | |
Bram Moolenaar | afe8cf6 | 2020-10-05 20:07:18 +0200 | [diff] [blame] | 1483 | " completion of autocmd group after comma |
| 1484 | call feedkeys(":doautocmd BufNew,BufEn\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1485 | call assert_equal("\"doautocmd BufNew,BufEnter", @:) |
| 1486 | |
Dominique Pelle | bfb2bb1 | 2021-08-14 21:11:51 +0200 | [diff] [blame] | 1487 | " completion of file name in :doautocmd |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 1488 | call writefile([], 'Xvarfile1', 'D') |
| 1489 | call writefile([], 'Xvarfile2', 'D') |
Bram Moolenaar | 61abe7d | 2022-08-30 21:46:08 +0100 | [diff] [blame] | 1490 | call feedkeys(":doautocmd BufEnter Xvarfi\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1491 | call assert_equal("\"doautocmd BufEnter Xvarfile1 Xvarfile2", @:) |
Dominique Pelle | bfb2bb1 | 2021-08-14 21:11:51 +0200 | [diff] [blame] | 1492 | |
Bram Moolenaar | 24ebd83 | 2020-03-16 21:25:24 +0100 | [diff] [blame] | 1493 | " completion for the :augroup command |
Bram Moolenaar | b4d82e2 | 2021-09-01 13:03:39 +0200 | [diff] [blame] | 1494 | augroup XTest.test |
Bram Moolenaar | 24ebd83 | 2020-03-16 21:25:24 +0100 | [diff] [blame] | 1495 | augroup END |
| 1496 | call feedkeys(":augroup X\<C-A>\<C-B>\"\<CR>", 'xt') |
Bram Moolenaar | b4d82e2 | 2021-09-01 13:03:39 +0200 | [diff] [blame] | 1497 | call assert_equal("\"augroup XTest.test", @:) |
Yegappan Lakshmanan | 00e977c | 2022-06-01 12:31:53 +0100 | [diff] [blame] | 1498 | |
| 1499 | " group name completion in :autocmd |
Bram Moolenaar | b4d82e2 | 2021-09-01 13:03:39 +0200 | [diff] [blame] | 1500 | call feedkeys(":au X\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1501 | call assert_equal("\"au XTest.test", @:) |
Yegappan Lakshmanan | 00e977c | 2022-06-01 12:31:53 +0100 | [diff] [blame] | 1502 | call feedkeys(":au XTest.test\<Tab>\<C-B>\"\<CR>", 'xt') |
| 1503 | call assert_equal("\"au XTest.test", @:) |
| 1504 | |
Bram Moolenaar | b4d82e2 | 2021-09-01 13:03:39 +0200 | [diff] [blame] | 1505 | augroup! XTest.test |
Bram Moolenaar | 24ebd83 | 2020-03-16 21:25:24 +0100 | [diff] [blame] | 1506 | |
Yegappan Lakshmanan | 00e977c | 2022-06-01 12:31:53 +0100 | [diff] [blame] | 1507 | " autocmd pattern completion |
| 1508 | call feedkeys(":au BufEnter *.py\<Tab>\<C-B>\"\<CR>", 'xt') |
| 1509 | call assert_equal("\"au BufEnter *.py\t", @:) |
| 1510 | |
Bram Moolenaar | 24ebd83 | 2020-03-16 21:25:24 +0100 | [diff] [blame] | 1511 | " completion for the :unlet command |
| 1512 | call feedkeys(":unlet one two\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1513 | call assert_equal("\"unlet one two", @:) |
| 1514 | |
Bram Moolenaar | 21c1a0c | 2021-10-17 17:20:23 +0100 | [diff] [blame] | 1515 | " completion for the :buffer command with curlies |
Bram Moolenaar | 39c47c3 | 2021-10-17 18:05:26 +0100 | [diff] [blame] | 1516 | " FIXME: what should happen on MS-Windows? |
| 1517 | if !has('win32') |
| 1518 | edit \{someFile} |
| 1519 | call feedkeys(":buf someFile\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1520 | call assert_equal("\"buf {someFile}", @:) |
| 1521 | bwipe {someFile} |
| 1522 | endif |
Bram Moolenaar | 21c1a0c | 2021-10-17 17:20:23 +0100 | [diff] [blame] | 1523 | |
Bram Moolenaar | 24ebd83 | 2020-03-16 21:25:24 +0100 | [diff] [blame] | 1524 | " completion for the :bdelete command |
| 1525 | call feedkeys(":bdel a b c\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1526 | call assert_equal("\"bdel a b c", @:) |
| 1527 | |
| 1528 | " completion for the :mapclear command |
| 1529 | call feedkeys(":mapclear \<C-A>\<C-B>\"\<CR>", 'xt') |
| 1530 | call assert_equal("\"mapclear <buffer>", @:) |
| 1531 | |
| 1532 | " completion for user defined commands with menu names |
| 1533 | menu Test.foo :ls<CR> |
| 1534 | com -nargs=* -complete=menu MyCmd |
| 1535 | call feedkeys(":MyCmd Te\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1536 | call assert_equal('"MyCmd Test.', @:) |
| 1537 | delcom MyCmd |
| 1538 | unmenu Test |
| 1539 | |
| 1540 | " completion for user defined commands with mappings |
| 1541 | mapclear |
| 1542 | map <F3> :ls<CR> |
| 1543 | com -nargs=* -complete=mapping MyCmd |
| 1544 | call feedkeys(":MyCmd <F\<C-A>\<C-B>\"\<CR>", 'xt') |
Yegappan Lakshmanan | 9773db6 | 2022-02-14 11:10:59 +0000 | [diff] [blame] | 1545 | call assert_equal('"MyCmd <F3> <F4>', @:) |
Bram Moolenaar | 24ebd83 | 2020-03-16 21:25:24 +0100 | [diff] [blame] | 1546 | mapclear |
| 1547 | delcom MyCmd |
| 1548 | |
Yee Cheng Chin | 5484485 | 2023-10-09 18:12:31 +0200 | [diff] [blame] | 1549 | " Prepare for path completion |
| 1550 | call mkdir('Xa b c', 'D') |
| 1551 | defer delete('Xcomma,foobar.txt') |
| 1552 | call writefile([], 'Xcomma,foobar.txt') |
| 1553 | |
Bram Moolenaar | 24ebd83 | 2020-03-16 21:25:24 +0100 | [diff] [blame] | 1554 | " completion for :set path= with multiple backslashes |
Yee Cheng Chin | 5484485 | 2023-10-09 18:12:31 +0200 | [diff] [blame] | 1555 | call feedkeys(':set path=Xa\\\ b' .. "\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1556 | call assert_equal('"set path=Xa\\\ b\\\ c/', @:) |
| 1557 | set path& |
Bram Moolenaar | 24ebd83 | 2020-03-16 21:25:24 +0100 | [diff] [blame] | 1558 | |
| 1559 | " completion for :set dir= with a backslash |
Yee Cheng Chin | 5484485 | 2023-10-09 18:12:31 +0200 | [diff] [blame] | 1560 | call feedkeys(':set dir=Xa\ b' .. "\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1561 | call assert_equal('"set dir=Xa\ b\ c/', @:) |
| 1562 | set dir& |
| 1563 | |
| 1564 | " completion for :set tags= / set dictionary= with escaped commas |
| 1565 | if has('win32') |
| 1566 | " In Windows backslashes are rounded up, so both '\,' and '\\,' escape to |
| 1567 | " '\,' |
| 1568 | call feedkeys(':set dictionary=Xcomma\,foo' .. "\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1569 | call assert_equal('"set dictionary=Xcomma\,foobar.txt', @:) |
| 1570 | |
| 1571 | call feedkeys(':set tags=Xcomma\\,foo' .. "\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1572 | call assert_equal('"set tags=Xcomma\,foobar.txt', @:) |
| 1573 | |
| 1574 | call feedkeys(':set tags=Xcomma\\\,foo' .. "\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1575 | call assert_equal('"set tags=Xcomma\\\,foo', @:) " Didn't find a match |
| 1576 | |
| 1577 | " completion for :set dictionary= with escaped commas (same behavior, but |
| 1578 | " different internal code path from 'set tags=' for escaping the output) |
| 1579 | call feedkeys(':set tags=Xcomma\\,foo' .. "\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1580 | call assert_equal('"set tags=Xcomma\,foobar.txt', @:) |
| 1581 | else |
| 1582 | " In other platforms, backslashes are rounded down (since '\,' itself will |
| 1583 | " be escaped into ','). As a result '\\,' and '\\\,' escape to '\,'. |
| 1584 | call feedkeys(':set tags=Xcomma\,foo' .. "\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1585 | call assert_equal('"set tags=Xcomma\,foo', @:) " Didn't find a match |
| 1586 | |
| 1587 | call feedkeys(':set tags=Xcomma\\,foo' .. "\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1588 | call assert_equal('"set tags=Xcomma\\,foobar.txt', @:) |
| 1589 | |
| 1590 | call feedkeys(':set dictionary=Xcomma\\\,foo' .. "\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1591 | call assert_equal('"set dictionary=Xcomma\\,foobar.txt', @:) |
| 1592 | |
| 1593 | " completion for :set dictionary= with escaped commas (same behavior, but |
| 1594 | " different internal code path from 'set tags=' for escaping the output) |
| 1595 | call feedkeys(':set dictionary=Xcomma\\,foo' .. "\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1596 | call assert_equal('"set dictionary=Xcomma\\,foobar.txt', @:) |
| 1597 | endif |
| 1598 | set tags& |
| 1599 | set dictionary& |
| 1600 | |
| 1601 | " completion for :set makeprg= with no escaped commas |
| 1602 | call feedkeys(':set makeprg=Xcomma,foo' .. "\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1603 | call assert_equal('"set makeprg=Xcomma,foobar.txt', @:) |
| 1604 | |
| 1605 | if !has('win32') |
| 1606 | " Cannot create file with backslash in file name in Windows, so only test |
| 1607 | " this elsewhere. |
| 1608 | defer delete('Xcomma\,fooslash.txt') |
| 1609 | call writefile([], 'Xcomma\,fooslash.txt') |
| 1610 | call feedkeys(':set makeprg=Xcomma\\,foo' .. "\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1611 | call assert_equal('"set makeprg=Xcomma\\,fooslash.txt', @:) |
| 1612 | endif |
| 1613 | set makeprg& |
Bram Moolenaar | 24ebd83 | 2020-03-16 21:25:24 +0100 | [diff] [blame] | 1614 | |
| 1615 | " completion for the :py3 commands |
| 1616 | call feedkeys(":py3\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1617 | call assert_equal('"py3 py3do py3file', @:) |
| 1618 | |
Bram Moolenaar | df749a2 | 2021-03-28 15:29:43 +0200 | [diff] [blame] | 1619 | " completion for the :vim9 commands |
| 1620 | call feedkeys(":vim9\<C-A>\<C-B>\"\<CR>", 'xt') |
| 1621 | call assert_equal('"vim9cmd vim9script', @:) |
| 1622 | |
Bram Moolenaar | 24ebd83 | 2020-03-16 21:25:24 +0100 | [diff] [blame] | 1623 | " redir @" is not the start of a comment. So complete after that |
| 1624 | call feedkeys(":redir @\" | cwin\t\<C-B>\"\<CR>", 'xt') |
| 1625 | call assert_equal('"redir @" | cwindow', @:) |
| 1626 | |
| 1627 | " completion after a backtick |
| 1628 | call feedkeys(":e `a1b2c\t\<C-B>\"\<CR>", 'xt') |
| 1629 | call assert_equal('"e `a1b2c', @:) |
| 1630 | |
Bram Moolenaar | 8dfcce3 | 2020-03-18 19:32:26 +0100 | [diff] [blame] | 1631 | " completion for :language command with an invalid argument |
| 1632 | call feedkeys(":language dummy \t\<C-B>\"\<CR>", 'xt') |
| 1633 | call assert_equal("\"language dummy \t", @:) |
| 1634 | |
| 1635 | " completion for commands after a :global command |
Bram Moolenaar | 8b63313 | 2020-03-20 18:20:51 +0100 | [diff] [blame] | 1636 | call feedkeys(":g/a\\xb/clearj\t\<C-B>\"\<CR>", 'xt') |
| 1637 | call assert_equal('"g/a\xb/clearjumps', @:) |
Bram Moolenaar | 8dfcce3 | 2020-03-18 19:32:26 +0100 | [diff] [blame] | 1638 | |
| 1639 | " completion with ambiguous user defined commands |
| 1640 | com TCmd1 echo 'TCmd1' |
| 1641 | com TCmd2 echo 'TCmd2' |
| 1642 | call feedkeys(":TCmd \t\<C-B>\"\<CR>", 'xt') |
| 1643 | call assert_equal('"TCmd ', @:) |
| 1644 | delcom TCmd1 |
| 1645 | delcom TCmd2 |
| 1646 | |
| 1647 | " completion after a range followed by a pipe (|) character |
| 1648 | call feedkeys(":1,10 | chist\t\<C-B>\"\<CR>", 'xt') |
| 1649 | call assert_equal('"1,10 | chistory', @:) |
Bram Moolenaar | 9c92971 | 2020-09-07 22:05:28 +0200 | [diff] [blame] | 1650 | |
Yegappan Lakshmanan | e3846cf | 2022-02-15 11:35:54 +0000 | [diff] [blame] | 1651 | " completion after a :global command |
| 1652 | call feedkeys(":g/a/chist\t\<C-B>\"\<CR>", 'xt') |
| 1653 | call assert_equal('"g/a/chistory', @:) |
| 1654 | call feedkeys(":g/a\\/chist\t\<C-B>\"\<CR>", 'xt') |
| 1655 | call assert_equal("\"g/a\\/chist\t", @:) |
| 1656 | |
Bram Moolenaar | 9c92971 | 2020-09-07 22:05:28 +0200 | [diff] [blame] | 1657 | " use <Esc> as the 'wildchar' for completion |
| 1658 | set wildchar=<Esc> |
| 1659 | call feedkeys(":g/a\\xb/clearj\<Esc>\<C-B>\"\<CR>", 'xt') |
| 1660 | call assert_equal('"g/a\xb/clearjumps', @:) |
| 1661 | " pressing <esc> twice should cancel the command |
| 1662 | call feedkeys(":chist\<Esc>\<Esc>", 'xt') |
| 1663 | call assert_equal('"g/a\xb/clearjumps', @:) |
| 1664 | set wildchar& |
Yegappan Lakshmanan | 4d03d87 | 2022-02-13 11:45:09 +0000 | [diff] [blame] | 1665 | |
Yegappan Lakshmanan | 4d03d87 | 2022-02-13 11:45:09 +0000 | [diff] [blame] | 1666 | if has('unix') |
Yegappan Lakshmanan | e3846cf | 2022-02-15 11:35:54 +0000 | [diff] [blame] | 1667 | " should be able to complete a file name that starts with a '~'. |
Yegappan Lakshmanan | 4d03d87 | 2022-02-13 11:45:09 +0000 | [diff] [blame] | 1668 | call writefile([], '~Xtest') |
| 1669 | call feedkeys(":e \\~X\<Tab>\<C-B>\"\<CR>", 'xt') |
| 1670 | call assert_equal('"e \~Xtest', @:) |
| 1671 | call delete('~Xtest') |
Yegappan Lakshmanan | e3846cf | 2022-02-15 11:35:54 +0000 | [diff] [blame] | 1672 | |
| 1673 | " should be able to complete a file name that has a '*' |
| 1674 | call writefile([], 'Xx*Yy') |
| 1675 | call feedkeys(":e Xx\*\<Tab>\<C-B>\"\<CR>", 'xt') |
| 1676 | call assert_equal('"e Xx\*Yy', @:) |
| 1677 | call delete('Xx*Yy') |
Yegappan Lakshmanan | b31aec3 | 2022-02-16 12:44:29 +0000 | [diff] [blame] | 1678 | |
| 1679 | " use a literal star |
| 1680 | call feedkeys(":e \\*\<Tab>\<C-B>\"\<CR>", 'xt') |
| 1681 | call assert_equal('"e \*', @:) |
Yegappan Lakshmanan | 4d03d87 | 2022-02-13 11:45:09 +0000 | [diff] [blame] | 1682 | endif |
Yegappan Lakshmanan | 9773db6 | 2022-02-14 11:10:59 +0000 | [diff] [blame] | 1683 | |
| 1684 | call feedkeys(":py3f\<Tab>\<C-B>\"\<CR>", 'xt') |
| 1685 | call assert_equal('"py3file', @:) |
Yegappan Lakshmanan | 4d03d87 | 2022-02-13 11:45:09 +0000 | [diff] [blame] | 1686 | endfunc |
| 1687 | |
zeertzjq | 094dd15 | 2023-06-15 22:51:57 +0100 | [diff] [blame] | 1688 | " Test that expanding a pattern doesn't interfere with cmdline completion. |
| 1689 | func Test_expand_during_cmdline_completion() |
| 1690 | func ExpandStuff() |
| 1691 | badd <script>:p:h/README.* |
| 1692 | call assert_equal(expand('<script>:p:h') .. '/README.txt', bufname('$')) |
| 1693 | $bwipe |
| 1694 | call assert_equal('README.txt', expand('README.*')) |
| 1695 | call assert_equal(['README.txt'], getcompletion('README.*', 'file')) |
| 1696 | endfunc |
| 1697 | augroup test_CmdlineChanged |
| 1698 | autocmd! |
| 1699 | autocmd CmdlineChanged * call ExpandStuff() |
| 1700 | augroup END |
| 1701 | |
| 1702 | call feedkeys(":sign \<Tab>\<Tab>\<Tab>\<Tab>\<C-B>\"\<CR>", 'xt') |
| 1703 | call assert_equal('"sign place', @:) |
| 1704 | |
| 1705 | augroup test_CmdlineChanged |
| 1706 | au! |
| 1707 | augroup END |
| 1708 | augroup! test_CmdlineChanged |
| 1709 | delfunc ExpandStuff |
| 1710 | endfunc |
| 1711 | |
Yegappan Lakshmanan | 4d03d87 | 2022-02-13 11:45:09 +0000 | [diff] [blame] | 1712 | " Test for 'wildignorecase' |
| 1713 | func Test_cmdline_wildignorecase() |
| 1714 | CheckUnix |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 1715 | call writefile([], 'XTEST', 'D') |
Yegappan Lakshmanan | 4d03d87 | 2022-02-13 11:45:09 +0000 | [diff] [blame] | 1716 | set wildignorecase |
| 1717 | call feedkeys(":e xt\<Tab>\<C-B>\"\<CR>", 'xt') |
| 1718 | call assert_equal('"e XTEST', @:) |
Yegappan Lakshmanan | 9773db6 | 2022-02-14 11:10:59 +0000 | [diff] [blame] | 1719 | call assert_equal(['XTEST'], getcompletion('xt', 'file')) |
Yegappan Lakshmanan | e3846cf | 2022-02-15 11:35:54 +0000 | [diff] [blame] | 1720 | let g:Sline = '' |
| 1721 | call feedkeys(":e xt\<C-d>\<F4>\<C-B>\"\<CR>", 'xt') |
| 1722 | call assert_equal('"e xt', @:) |
| 1723 | call assert_equal('XTEST', g:Sline) |
Yegappan Lakshmanan | 4d03d87 | 2022-02-13 11:45:09 +0000 | [diff] [blame] | 1724 | set wildignorecase& |
Bram Moolenaar | 24ebd83 | 2020-03-16 21:25:24 +0100 | [diff] [blame] | 1725 | endfunc |
| 1726 | |
Bram Moolenaar | c312b8b | 2017-10-28 17:53:04 +0200 | [diff] [blame] | 1727 | func Test_cmdline_write_alternatefile() |
| 1728 | new |
| 1729 | call setline('.', ['one', 'two']) |
| 1730 | f foo.txt |
| 1731 | new |
| 1732 | f #-A |
| 1733 | call assert_equal('foo.txt-A', expand('%')) |
| 1734 | f #<-B.txt |
| 1735 | call assert_equal('foo-B.txt', expand('%')) |
| 1736 | f %< |
| 1737 | call assert_equal('foo-B', expand('%')) |
| 1738 | new |
Bram Moolenaar | e2e4075 | 2020-09-04 21:18:46 +0200 | [diff] [blame] | 1739 | call assert_fails('f #<', 'E95:') |
Bram Moolenaar | c312b8b | 2017-10-28 17:53:04 +0200 | [diff] [blame] | 1740 | bw! |
| 1741 | f foo-B.txt |
| 1742 | f %<-A |
| 1743 | call assert_equal('foo-B-A', expand('%')) |
| 1744 | bw! |
| 1745 | bw! |
| 1746 | endfunc |
| 1747 | |
Bram Moolenaar | f572437 | 2022-09-02 19:45:15 +0100 | [diff] [blame] | 1748 | func Test_cmdline_expand_cur_alt_file() |
| 1749 | enew |
| 1750 | file http://some.com/file.txt |
| 1751 | call feedkeys(":e %\<Tab>\<C-B>\"\<CR>", 'xt') |
| 1752 | call assert_equal('"e http://some.com/file.txt', @:) |
| 1753 | edit another |
| 1754 | call feedkeys(":e #\<Tab>\<C-B>\"\<CR>", 'xt') |
| 1755 | call assert_equal('"e http://some.com/file.txt', @:) |
| 1756 | bwipe |
| 1757 | bwipe http://some.com/file.txt |
| 1758 | endfunc |
| 1759 | |
Bram Moolenaar | cbf20fb | 2017-02-03 21:19:04 +0100 | [diff] [blame] | 1760 | " using a leading backslash here |
| 1761 | set cpo+=C |
| 1762 | |
| 1763 | func Test_cmdline_search_range() |
| 1764 | new |
| 1765 | call setline(1, ['a', 'b', 'c', 'd']) |
| 1766 | /d |
| 1767 | 1,\/s/b/B/ |
| 1768 | call assert_equal('B', getline(2)) |
| 1769 | |
| 1770 | /a |
| 1771 | $ |
| 1772 | \?,4s/c/C/ |
| 1773 | call assert_equal('C', getline(3)) |
| 1774 | |
| 1775 | call setline(1, ['a', 'b', 'c', 'd']) |
| 1776 | %s/c/c/ |
| 1777 | 1,\&s/b/B/ |
| 1778 | call assert_equal('B', getline(2)) |
| 1779 | |
Bram Moolenaar | f0cee19 | 2020-02-16 13:33:56 +0100 | [diff] [blame] | 1780 | let @/ = 'apple' |
Bram Moolenaar | 9b7bf9e | 2020-07-11 22:14:59 +0200 | [diff] [blame] | 1781 | call assert_fails('\/print', ['E486:.*apple']) |
Bram Moolenaar | f0cee19 | 2020-02-16 13:33:56 +0100 | [diff] [blame] | 1782 | |
Bram Moolenaar | cbf20fb | 2017-02-03 21:19:04 +0100 | [diff] [blame] | 1783 | bwipe! |
| 1784 | endfunc |
| 1785 | |
Bram Moolenaar | f0cee19 | 2020-02-16 13:33:56 +0100 | [diff] [blame] | 1786 | " Test for the tick mark (') in an excmd range |
| 1787 | func Test_tick_mark_in_range() |
| 1788 | " If only the tick is passed as a range and no command is specified, there |
| 1789 | " should not be an error |
| 1790 | call feedkeys(":'\<CR>", 'xt') |
Yegappan Lakshmanan | e3846cf | 2022-02-15 11:35:54 +0000 | [diff] [blame] | 1791 | call assert_equal("'", @:) |
Bram Moolenaar | f0cee19 | 2020-02-16 13:33:56 +0100 | [diff] [blame] | 1792 | call assert_fails("',print", 'E78:') |
| 1793 | endfunc |
| 1794 | |
| 1795 | " Test for using a line number followed by a search pattern as range |
| 1796 | func Test_lnum_and_pattern_as_range() |
| 1797 | new |
| 1798 | call setline(1, ['foo 1', 'foo 2', 'foo 3']) |
| 1799 | let @" = '' |
| 1800 | 2/foo/yank |
| 1801 | call assert_equal("foo 3\n", @") |
| 1802 | call assert_equal(1, line('.')) |
| 1803 | close! |
| 1804 | endfunc |
| 1805 | |
Bram Moolenaar | 65189a1 | 2017-02-06 22:22:17 +0100 | [diff] [blame] | 1806 | " Tests for getcmdline(), getcmdpos() and getcmdtype() |
| 1807 | func Check_cmdline(cmdtype) |
| 1808 | call assert_equal('MyCmd a', getcmdline()) |
| 1809 | call assert_equal(8, getcmdpos()) |
| 1810 | call assert_equal(a:cmdtype, getcmdtype()) |
| 1811 | return '' |
| 1812 | endfunc |
| 1813 | |
Bram Moolenaar | 96e38a8 | 2019-09-09 18:35:33 +0200 | [diff] [blame] | 1814 | set cpo& |
| 1815 | |
Shougo Matsushita | 6908428 | 2024-09-23 20:34:47 +0200 | [diff] [blame] | 1816 | func Test_getcmdtype_getcmdprompt() |
Bram Moolenaar | 65189a1 | 2017-02-06 22:22:17 +0100 | [diff] [blame] | 1817 | call feedkeys(":MyCmd a\<C-R>=Check_cmdline(':')\<CR>\<Esc>", "xt") |
| 1818 | |
| 1819 | let cmdtype = '' |
| 1820 | debuggreedy |
| 1821 | call feedkeys(":debug echo 'test'\<CR>", "t") |
| 1822 | call feedkeys("let cmdtype = \<C-R>=string(getcmdtype())\<CR>\<CR>", "t") |
| 1823 | call feedkeys("cont\<CR>", "xt") |
| 1824 | 0debuggreedy |
| 1825 | call assert_equal('>', cmdtype) |
| 1826 | |
| 1827 | call feedkeys("/MyCmd a\<C-R>=Check_cmdline('/')\<CR>\<Esc>", "xt") |
| 1828 | call feedkeys("?MyCmd a\<C-R>=Check_cmdline('?')\<CR>\<Esc>", "xt") |
| 1829 | |
| 1830 | call feedkeys(":call input('Answer?')\<CR>", "t") |
Bram Moolenaar | 31eb139 | 2017-02-09 21:44:03 +0100 | [diff] [blame] | 1831 | call feedkeys("MyCmd a\<C-R>=Check_cmdline('@')\<CR>\<C-C>", "xt") |
Bram Moolenaar | 65189a1 | 2017-02-06 22:22:17 +0100 | [diff] [blame] | 1832 | |
| 1833 | call feedkeys(":insert\<CR>MyCmd a\<C-R>=Check_cmdline('-')\<CR>\<Esc>", "xt") |
| 1834 | |
| 1835 | cnoremap <expr> <F6> Check_cmdline('=') |
| 1836 | call feedkeys("a\<C-R>=MyCmd a\<F6>\<Esc>\<Esc>", "xt") |
| 1837 | cunmap <F6> |
Bram Moolenaar | 8d588cc | 2020-02-25 21:47:45 +0100 | [diff] [blame] | 1838 | |
| 1839 | call assert_equal('', getcmdline()) |
Shougo Matsushita | 6908428 | 2024-09-23 20:34:47 +0200 | [diff] [blame] | 1840 | |
| 1841 | call assert_equal('', getcmdprompt()) |
| 1842 | augroup test_CmdlineEnter |
| 1843 | autocmd! |
| 1844 | autocmd CmdlineEnter * let g:cmdprompt=getcmdprompt() |
| 1845 | augroup END |
| 1846 | call feedkeys(":call input('Answer?')\<CR>a\<CR>\<ESC>", "xt") |
| 1847 | call assert_equal('Answer?', g:cmdprompt) |
| 1848 | call assert_equal('', getcmdprompt()) |
h-east | 25876a6 | 2024-09-26 16:01:57 +0200 | [diff] [blame] | 1849 | call feedkeys(":\<CR>\<ESC>", "xt") |
| 1850 | call assert_equal('', g:cmdprompt) |
| 1851 | call assert_equal('', getcmdprompt()) |
| 1852 | |
| 1853 | let str = "C" .. repeat("c", 1023) .. "xyz" |
| 1854 | call feedkeys(":call input('" .. str .. "')\<CR>\<CR>\<ESC>", "xt") |
| 1855 | call assert_equal(str, g:cmdprompt) |
| 1856 | |
| 1857 | call feedkeys(':call input("Msg1\nMessage2\nAns?")' .. "\<CR>b\<CR>\<ESC>", "xt") |
| 1858 | call assert_equal('Ans?', g:cmdprompt) |
| 1859 | call assert_equal('', getcmdprompt()) |
Shougo Matsushita | 6908428 | 2024-09-23 20:34:47 +0200 | [diff] [blame] | 1860 | |
| 1861 | augroup test_CmdlineEnter |
| 1862 | au! |
| 1863 | augroup END |
| 1864 | augroup! test_CmdlineEnter |
Bram Moolenaar | 65189a1 | 2017-02-06 22:22:17 +0100 | [diff] [blame] | 1865 | endfunc |
| 1866 | |
Bram Moolenaar | 52604f2 | 2017-04-07 16:17:39 +0200 | [diff] [blame] | 1867 | func Test_verbosefile() |
| 1868 | set verbosefile=Xlog |
| 1869 | echomsg 'foo' |
| 1870 | echomsg 'bar' |
| 1871 | set verbosefile= |
| 1872 | let log = readfile('Xlog') |
| 1873 | call assert_match("foo\nbar", join(log, "\n")) |
| 1874 | call delete('Xlog') |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 1875 | |
| 1876 | call mkdir('Xdir', 'D') |
Bram Moolenaar | 9b7bf9e | 2020-07-11 22:14:59 +0200 | [diff] [blame] | 1877 | call assert_fails('set verbosefile=Xdir', ['E484:.*Xdir', 'E474:']) |
Bram Moolenaar | 52604f2 | 2017-04-07 16:17:39 +0200 | [diff] [blame] | 1878 | endfunc |
| 1879 | |
Bram Moolenaar | 4facea3 | 2019-10-12 20:17:40 +0200 | [diff] [blame] | 1880 | func Test_verbose_option() |
| 1881 | CheckScreendump |
| 1882 | |
| 1883 | let lines =<< trim [SCRIPT] |
Christian Brabandt | 2abec43 | 2024-10-27 21:33:09 +0100 | [diff] [blame] | 1884 | " clear the TermResponse autocommand from defaults.vim |
| 1885 | au! vimStartup TermResponse |
Bram Moolenaar | 4facea3 | 2019-10-12 20:17:40 +0200 | [diff] [blame] | 1886 | command DoSomething echo 'hello' |set ts=4 |let v = '123' |echo v |
| 1887 | call feedkeys("\r", 't') " for the hit-enter prompt |
| 1888 | set verbose=20 |
| 1889 | [SCRIPT] |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 1890 | call writefile(lines, 'XTest_verbose', 'D') |
Bram Moolenaar | 4facea3 | 2019-10-12 20:17:40 +0200 | [diff] [blame] | 1891 | |
| 1892 | let buf = RunVimInTerminal('-S XTest_verbose', {'rows': 12}) |
Bram Moolenaar | 6a2c5a7 | 2020-04-08 21:50:25 +0200 | [diff] [blame] | 1893 | call TermWait(buf, 50) |
Bram Moolenaar | 4facea3 | 2019-10-12 20:17:40 +0200 | [diff] [blame] | 1894 | call term_sendkeys(buf, ":DoSomething\<CR>") |
| 1895 | call VerifyScreenDump(buf, 'Test_verbose_option_1', {}) |
| 1896 | |
| 1897 | " clean up |
| 1898 | call StopVimInTerminal(buf) |
Bram Moolenaar | 4facea3 | 2019-10-12 20:17:40 +0200 | [diff] [blame] | 1899 | endfunc |
| 1900 | |
Bram Moolenaar | ff3be4f | 2018-05-12 13:18:46 +0200 | [diff] [blame] | 1901 | func Test_setcmdpos() |
| 1902 | func InsertTextAtPos(text, pos) |
| 1903 | call assert_equal(0, setcmdpos(a:pos)) |
| 1904 | return a:text |
| 1905 | endfunc |
| 1906 | |
| 1907 | " setcmdpos() with position in the middle of the command line. |
| 1908 | call feedkeys(":\"12\<C-R>=InsertTextAtPos('a', 3)\<CR>b\<CR>", 'xt') |
| 1909 | call assert_equal('"1ab2', @:) |
| 1910 | |
| 1911 | call feedkeys(":\"12\<C-R>\<C-R>=InsertTextAtPos('a', 3)\<CR>b\<CR>", 'xt') |
| 1912 | call assert_equal('"1b2a', @:) |
| 1913 | |
| 1914 | " setcmdpos() with position beyond the end of the command line. |
| 1915 | call feedkeys(":\"12\<C-B>\<C-R>=InsertTextAtPos('a', 10)\<CR>b\<CR>", 'xt') |
| 1916 | call assert_equal('"12ab', @:) |
| 1917 | |
| 1918 | " setcmdpos() returns 1 when not editing the command line. |
Bram Moolenaar | 196b466 | 2019-09-06 21:34:30 +0200 | [diff] [blame] | 1919 | call assert_equal(1, 3->setcmdpos()) |
Bram Moolenaar | ff3be4f | 2018-05-12 13:18:46 +0200 | [diff] [blame] | 1920 | endfunc |
| 1921 | |
Bram Moolenaar | c0676ba | 2018-12-31 21:03:02 +0100 | [diff] [blame] | 1922 | func Test_cmdline_overstrike() |
Bram Moolenaar | 30276f2 | 2019-01-24 17:59:39 +0100 | [diff] [blame] | 1923 | let encodings = ['latin1', 'utf8'] |
Bram Moolenaar | c0676ba | 2018-12-31 21:03:02 +0100 | [diff] [blame] | 1924 | let encoding_save = &encoding |
| 1925 | |
| 1926 | for e in encodings |
| 1927 | exe 'set encoding=' . e |
| 1928 | |
| 1929 | " Test overstrike in the middle of the command line. |
| 1930 | call feedkeys(":\"01234\<home>\<right>\<right>ab\<right>\<insert>cd\<enter>", 'xt') |
Bram Moolenaar | 59cb041 | 2019-12-18 22:26:31 +0100 | [diff] [blame] | 1931 | call assert_equal('"0ab1cd4', @:, e) |
Bram Moolenaar | c0676ba | 2018-12-31 21:03:02 +0100 | [diff] [blame] | 1932 | |
| 1933 | " Test overstrike going beyond end of command line. |
| 1934 | call feedkeys(":\"01234\<home>\<right>\<right>ab\<right>\<insert>cdefgh\<enter>", 'xt') |
Bram Moolenaar | 59cb041 | 2019-12-18 22:26:31 +0100 | [diff] [blame] | 1935 | call assert_equal('"0ab1cdefgh', @:, e) |
Bram Moolenaar | c0676ba | 2018-12-31 21:03:02 +0100 | [diff] [blame] | 1936 | |
| 1937 | " Test toggling insert/overstrike a few times. |
| 1938 | call feedkeys(":\"01234\<home>\<right>ab\<right>\<insert>cd\<right>\<insert>ef\<enter>", 'xt') |
Bram Moolenaar | 59cb041 | 2019-12-18 22:26:31 +0100 | [diff] [blame] | 1939 | call assert_equal('"ab0cd3ef4', @:, e) |
Bram Moolenaar | c0676ba | 2018-12-31 21:03:02 +0100 | [diff] [blame] | 1940 | endfor |
| 1941 | |
Bram Moolenaar | 30276f2 | 2019-01-24 17:59:39 +0100 | [diff] [blame] | 1942 | " Test overstrike with multi-byte characters. |
| 1943 | call feedkeys(":\"テキストエディタ\<home>\<right>\<right>ab\<right>\<insert>cd\<enter>", 'xt') |
Bram Moolenaar | 59cb041 | 2019-12-18 22:26:31 +0100 | [diff] [blame] | 1944 | call assert_equal('"テabキcdエディタ', @:, e) |
Bram Moolenaar | c0676ba | 2018-12-31 21:03:02 +0100 | [diff] [blame] | 1945 | |
| 1946 | let &encoding = encoding_save |
| 1947 | endfunc |
Bram Moolenaar | a046b37 | 2019-09-15 17:26:07 +0200 | [diff] [blame] | 1948 | |
Bram Moolenaar | 5241057 | 2019-10-27 05:12:45 +0100 | [diff] [blame] | 1949 | func Test_buffers_lastused() |
| 1950 | " check that buffers are sorted by time when wildmode has lastused |
| 1951 | call test_settime(1550020000) " middle |
| 1952 | edit bufa |
| 1953 | enew |
| 1954 | call test_settime(1550030000) " newest |
| 1955 | edit bufb |
| 1956 | enew |
| 1957 | call test_settime(1550010000) " oldest |
| 1958 | edit bufc |
| 1959 | enew |
| 1960 | call test_settime(0) |
| 1961 | enew |
| 1962 | |
| 1963 | call assert_equal(['bufa', 'bufb', 'bufc'], |
| 1964 | \ getcompletion('', 'buffer')) |
| 1965 | |
| 1966 | let save_wildmode = &wildmode |
| 1967 | set wildmode=full:lastused |
| 1968 | |
| 1969 | let cap = "\<c-r>=execute('let X=getcmdline()')\<cr>" |
| 1970 | call feedkeys(":b \<tab>" .. cap .. "\<esc>", 'xt') |
| 1971 | call assert_equal('b bufb', X) |
| 1972 | call feedkeys(":b \<tab>\<tab>" .. cap .. "\<esc>", 'xt') |
| 1973 | call assert_equal('b bufa', X) |
| 1974 | call feedkeys(":b \<tab>\<tab>\<tab>" .. cap .. "\<esc>", 'xt') |
| 1975 | call assert_equal('b bufc', X) |
| 1976 | enew |
| 1977 | |
| 1978 | edit other |
| 1979 | call feedkeys(":b \<tab>" .. cap .. "\<esc>", 'xt') |
| 1980 | call assert_equal('b bufb', X) |
| 1981 | call feedkeys(":b \<tab>\<tab>" .. cap .. "\<esc>", 'xt') |
| 1982 | call assert_equal('b bufa', X) |
| 1983 | call feedkeys(":b \<tab>\<tab>\<tab>" .. cap .. "\<esc>", 'xt') |
| 1984 | call assert_equal('b bufc', X) |
| 1985 | enew |
| 1986 | |
| 1987 | let &wildmode = save_wildmode |
| 1988 | |
| 1989 | bwipeout bufa |
| 1990 | bwipeout bufb |
| 1991 | bwipeout bufc |
| 1992 | endfunc |
Bram Moolenaar | 85db547 | 2019-12-04 15:11:08 +0100 | [diff] [blame] | 1993 | |
Bram Moolenaar | 479950f | 2020-01-19 15:45:17 +0100 | [diff] [blame] | 1994 | func Test_cmdlineclear_tabenter() |
| 1995 | CheckScreendump |
| 1996 | |
| 1997 | let lines =<< trim [SCRIPT] |
| 1998 | call setline(1, range(30)) |
| 1999 | [SCRIPT] |
| 2000 | |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 2001 | call writefile(lines, 'XtestCmdlineClearTabenter', 'D') |
Bram Moolenaar | 479950f | 2020-01-19 15:45:17 +0100 | [diff] [blame] | 2002 | let buf = RunVimInTerminal('-S XtestCmdlineClearTabenter', #{rows: 10}) |
Bram Moolenaar | 6a2c5a7 | 2020-04-08 21:50:25 +0200 | [diff] [blame] | 2003 | call TermWait(buf, 25) |
Bram Moolenaar | 479950f | 2020-01-19 15:45:17 +0100 | [diff] [blame] | 2004 | " in one tab make the command line higher with CTRL-W - |
| 2005 | call term_sendkeys(buf, ":tabnew\<cr>\<C-w>-\<C-w>-gtgt") |
| 2006 | call VerifyScreenDump(buf, 'Test_cmdlineclear_tabenter', {}) |
| 2007 | |
| 2008 | call StopVimInTerminal(buf) |
Bram Moolenaar | 479950f | 2020-01-19 15:45:17 +0100 | [diff] [blame] | 2009 | endfunc |
| 2010 | |
Yegappan Lakshmanan | 46aa6f9 | 2021-05-19 17:15:04 +0200 | [diff] [blame] | 2011 | " Test for expanding special keywords in cmdline |
Bram Moolenaar | 9f6277b | 2020-02-11 22:04:02 +0100 | [diff] [blame] | 2012 | func Test_cmdline_expand_special() |
| 2013 | %bwipe! |
Bram Moolenaar | b8bd2e6 | 2021-08-21 17:13:14 +0200 | [diff] [blame] | 2014 | call assert_fails('e #', 'E194:') |
Bram Moolenaar | 9f6277b | 2020-02-11 22:04:02 +0100 | [diff] [blame] | 2015 | call assert_fails('e <afile>', 'E495:') |
| 2016 | call assert_fails('e <abuf>', 'E496:') |
| 2017 | call assert_fails('e <amatch>', 'E497:') |
Yegappan Lakshmanan | 46aa6f9 | 2021-05-19 17:15:04 +0200 | [diff] [blame] | 2018 | |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 2019 | call writefile([], 'Xfile.cpp', 'D') |
| 2020 | call writefile([], 'Xfile.java', 'D') |
Yegappan Lakshmanan | 46aa6f9 | 2021-05-19 17:15:04 +0200 | [diff] [blame] | 2021 | new Xfile.cpp |
| 2022 | call feedkeys(":e %:r\<C-A>\<C-B>\"\<CR>", 'xt') |
| 2023 | call assert_equal('"e Xfile.cpp Xfile.java', @:) |
| 2024 | close |
Bram Moolenaar | 9f6277b | 2020-02-11 22:04:02 +0100 | [diff] [blame] | 2025 | endfunc |
| 2026 | |
Bram Moolenaar | f0cee19 | 2020-02-16 13:33:56 +0100 | [diff] [blame] | 2027 | " Test for backtick expression in the command line |
| 2028 | func Test_cmd_backtick() |
| 2029 | %argd |
| 2030 | argadd `=['a', 'b', 'c']` |
| 2031 | call assert_equal(['a', 'b', 'c'], argv()) |
| 2032 | %argd |
Dominique Pelle | bfb2bb1 | 2021-08-14 21:11:51 +0200 | [diff] [blame] | 2033 | |
| 2034 | argadd `echo abc def` |
| 2035 | call assert_equal(['abc def'], argv()) |
| 2036 | %argd |
Bram Moolenaar | f0cee19 | 2020-02-16 13:33:56 +0100 | [diff] [blame] | 2037 | endfunc |
| 2038 | |
Bram Moolenaar | 818fc9a | 2020-02-21 17:54:45 +0100 | [diff] [blame] | 2039 | " Test for the :! command |
| 2040 | func Test_cmd_bang() |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 2041 | CheckUnix |
Bram Moolenaar | 818fc9a | 2020-02-21 17:54:45 +0100 | [diff] [blame] | 2042 | |
| 2043 | let lines =<< trim [SCRIPT] |
| 2044 | " Test for no previous command |
| 2045 | call assert_fails('!!', 'E34:') |
| 2046 | set nomore |
| 2047 | " Test for cmdline expansion with :! |
| 2048 | call setline(1, 'foo!') |
| 2049 | silent !echo <cWORD> > Xfile.out |
| 2050 | call assert_equal(['foo!'], readfile('Xfile.out')) |
| 2051 | " Test for using previous command |
| 2052 | silent !echo \! ! |
| 2053 | call assert_equal(['! echo foo!'], readfile('Xfile.out')) |
| 2054 | call writefile(v:errors, 'Xresult') |
| 2055 | call delete('Xfile.out') |
| 2056 | qall! |
| 2057 | [SCRIPT] |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 2058 | call writefile(lines, 'Xscript', 'D') |
Bram Moolenaar | 818fc9a | 2020-02-21 17:54:45 +0100 | [diff] [blame] | 2059 | if RunVim([], [], '--clean -S Xscript') |
| 2060 | call assert_equal([], readfile('Xresult')) |
| 2061 | endif |
Bram Moolenaar | 818fc9a | 2020-02-21 17:54:45 +0100 | [diff] [blame] | 2062 | call delete('Xresult') |
| 2063 | endfunc |
| 2064 | |
Bram Moolenaar | e0c3c3d | 2020-06-04 22:46:04 +0200 | [diff] [blame] | 2065 | " Test error: "E135: *Filter* Autocommands must not change current buffer" |
| 2066 | func Test_cmd_bang_E135() |
| 2067 | new |
| 2068 | call setline(1, ['a', 'b', 'c', 'd']) |
| 2069 | augroup test_cmd_filter_E135 |
| 2070 | au! |
| 2071 | autocmd FilterReadPost * help |
| 2072 | augroup END |
| 2073 | call assert_fails('2,3!echo "x"', 'E135:') |
| 2074 | |
| 2075 | augroup test_cmd_filter_E135 |
| 2076 | au! |
| 2077 | augroup END |
zeertzjq | 094dd15 | 2023-06-15 22:51:57 +0100 | [diff] [blame] | 2078 | augroup! test_cmd_filter_E135 |
Bram Moolenaar | e0c3c3d | 2020-06-04 22:46:04 +0200 | [diff] [blame] | 2079 | %bwipe! |
| 2080 | endfunc |
| 2081 | |
shane.xb.qian | 4e7590e | 2022-11-08 21:40:04 +0000 | [diff] [blame] | 2082 | func Test_cmd_bang_args() |
| 2083 | new |
| 2084 | :.! |
| 2085 | call assert_equal(0, v:shell_error) |
| 2086 | |
| 2087 | " Note that below there is one space char after the '!'. This caused a |
| 2088 | " shell error in the past, see https://github.com/vim/vim/issues/11495. |
| 2089 | :.! |
| 2090 | call assert_equal(0, v:shell_error) |
| 2091 | bwipe! |
| 2092 | |
| 2093 | CheckUnix |
| 2094 | :.!pwd |
| 2095 | call assert_equal(0, v:shell_error) |
| 2096 | :.! pwd |
| 2097 | call assert_equal(0, v:shell_error) |
| 2098 | |
| 2099 | " Note there is one space after 'pwd'. |
| 2100 | :.! pwd |
| 2101 | call assert_equal(0, v:shell_error) |
| 2102 | |
| 2103 | " Note there are two spaces after 'pwd'. |
| 2104 | :.! pwd |
| 2105 | call assert_equal(0, v:shell_error) |
| 2106 | :.!ls ~ |
| 2107 | call assert_equal(0, v:shell_error) |
| 2108 | |
| 2109 | " Note there is one space char after '~'. |
| 2110 | :.!ls ~ |
| 2111 | call assert_equal(0, v:shell_error) |
| 2112 | |
| 2113 | " Note there are two spaces after '~'. |
| 2114 | :.!ls ~ |
| 2115 | call assert_equal(0, v:shell_error) |
| 2116 | |
| 2117 | :.!echo "foo" |
| 2118 | call assert_equal(getline('.'), "foo") |
| 2119 | :.!echo "foo " |
| 2120 | call assert_equal(getline('.'), "foo ") |
| 2121 | :.!echo " foo " |
| 2122 | call assert_equal(getline('.'), " foo ") |
| 2123 | :.!echo " foo " |
| 2124 | call assert_equal(getline('.'), " foo ") |
| 2125 | |
| 2126 | %bwipe! |
| 2127 | endfunc |
| 2128 | |
Bram Moolenaar | 8d588cc | 2020-02-25 21:47:45 +0100 | [diff] [blame] | 2129 | " Test for using ~ for home directory in cmdline completion matches |
| 2130 | func Test_cmdline_expand_home() |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 2131 | call mkdir('Xexpdir', 'R') |
Bram Moolenaar | 61abe7d | 2022-08-30 21:46:08 +0100 | [diff] [blame] | 2132 | call writefile([], 'Xexpdir/Xfile1') |
| 2133 | call writefile([], 'Xexpdir/Xfile2') |
| 2134 | cd Xexpdir |
Bram Moolenaar | 8d588cc | 2020-02-25 21:47:45 +0100 | [diff] [blame] | 2135 | let save_HOME = $HOME |
| 2136 | let $HOME = getcwd() |
| 2137 | call feedkeys(":e ~/\<C-A>\<C-B>\"\<CR>", 'xt') |
| 2138 | call assert_equal('"e ~/Xfile1 ~/Xfile2', @:) |
| 2139 | let $HOME = save_HOME |
| 2140 | cd .. |
Bram Moolenaar | 8d588cc | 2020-02-25 21:47:45 +0100 | [diff] [blame] | 2141 | endfunc |
| 2142 | |
Bram Moolenaar | 578fe94 | 2020-02-27 21:32:51 +0100 | [diff] [blame] | 2143 | " Test for using CTRL-\ CTRL-G in the command line to go back to normal mode |
| 2144 | " or insert mode (when 'insertmode' is set) |
| 2145 | func Test_cmdline_ctrl_g() |
| 2146 | new |
| 2147 | call setline(1, 'abc') |
| 2148 | call cursor(1, 3) |
| 2149 | " If command line is entered from insert mode, using C-\ C-G should back to |
| 2150 | " insert mode |
| 2151 | call feedkeys("i\<C-O>:\<C-\>\<C-G>xy", 'xt') |
| 2152 | call assert_equal('abxyc', getline(1)) |
| 2153 | call assert_equal(4, col('.')) |
| 2154 | |
| 2155 | " If command line is entered in 'insertmode', using C-\ C-G should back to |
| 2156 | " 'insertmode' |
| 2157 | call feedkeys(":set im\<cr>\<C-L>:\<C-\>\<C-G>12\<C-L>:set noim\<cr>", 'xt') |
| 2158 | call assert_equal('ab12xyc', getline(1)) |
| 2159 | close! |
| 2160 | endfunc |
| 2161 | |
Bram Moolenaar | 578fe94 | 2020-02-27 21:32:51 +0100 | [diff] [blame] | 2162 | " Test for 'wildmode' |
Yegappan Lakshmanan | 9773db6 | 2022-02-14 11:10:59 +0000 | [diff] [blame] | 2163 | func Wildmode_tests() |
Bram Moolenaar | 578fe94 | 2020-02-27 21:32:51 +0100 | [diff] [blame] | 2164 | func T(a, c, p) |
| 2165 | return "oneA\noneB\noneC" |
| 2166 | endfunc |
| 2167 | command -nargs=1 -complete=custom,T MyCmd |
| 2168 | |
Bram Moolenaar | 578fe94 | 2020-02-27 21:32:51 +0100 | [diff] [blame] | 2169 | set nowildmenu |
| 2170 | set wildmode=full,list |
| 2171 | let g:Sline = '' |
Yegappan Lakshmanan | 9773db6 | 2022-02-14 11:10:59 +0000 | [diff] [blame] | 2172 | call feedkeys(":MyCmd \t\t\<F4>\<C-B>\"\<CR>", 'xt') |
Bram Moolenaar | 24ebd83 | 2020-03-16 21:25:24 +0100 | [diff] [blame] | 2173 | call assert_equal('oneA oneB oneC', g:Sline) |
Bram Moolenaar | 578fe94 | 2020-02-27 21:32:51 +0100 | [diff] [blame] | 2174 | call assert_equal('"MyCmd oneA', @:) |
| 2175 | |
| 2176 | set wildmode=longest,full |
| 2177 | call feedkeys(":MyCmd o\t\<C-B>\"\<CR>", 'xt') |
| 2178 | call assert_equal('"MyCmd one', @:) |
| 2179 | call feedkeys(":MyCmd o\t\t\t\t\<C-B>\"\<CR>", 'xt') |
| 2180 | call assert_equal('"MyCmd oneC', @:) |
| 2181 | |
| 2182 | set wildmode=longest |
| 2183 | call feedkeys(":MyCmd one\t\t\<C-B>\"\<CR>", 'xt') |
| 2184 | call assert_equal('"MyCmd one', @:) |
| 2185 | |
| 2186 | set wildmode=list:longest |
| 2187 | let g:Sline = '' |
Yegappan Lakshmanan | 9773db6 | 2022-02-14 11:10:59 +0000 | [diff] [blame] | 2188 | call feedkeys(":MyCmd \t\<F4>\<C-B>\"\<CR>", 'xt') |
Bram Moolenaar | 24ebd83 | 2020-03-16 21:25:24 +0100 | [diff] [blame] | 2189 | call assert_equal('oneA oneB oneC', g:Sline) |
Bram Moolenaar | 578fe94 | 2020-02-27 21:32:51 +0100 | [diff] [blame] | 2190 | call assert_equal('"MyCmd one', @:) |
| 2191 | |
| 2192 | set wildmode="" |
| 2193 | call feedkeys(":MyCmd \t\t\<C-B>\"\<CR>", 'xt') |
| 2194 | call assert_equal('"MyCmd oneA', @:) |
| 2195 | |
Bram Moolenaar | 24ebd83 | 2020-03-16 21:25:24 +0100 | [diff] [blame] | 2196 | " Test for wildmode=longest with 'fileignorecase' set |
| 2197 | set wildmode=longest |
| 2198 | set fileignorecase |
Bram Moolenaar | 8dfcce3 | 2020-03-18 19:32:26 +0100 | [diff] [blame] | 2199 | argadd AAA AAAA AAAAA |
| 2200 | call feedkeys(":buffer a\t\<C-B>\"\<CR>", 'xt') |
| 2201 | call assert_equal('"buffer AAA', @:) |
Bram Moolenaar | 24ebd83 | 2020-03-16 21:25:24 +0100 | [diff] [blame] | 2202 | set fileignorecase& |
| 2203 | |
| 2204 | " Test for listing files with wildmode=list |
| 2205 | set wildmode=list |
| 2206 | let g:Sline = '' |
Yegappan Lakshmanan | 9773db6 | 2022-02-14 11:10:59 +0000 | [diff] [blame] | 2207 | call feedkeys(":b A\t\t\<F4>\<C-B>\"\<CR>", 'xt') |
Bram Moolenaar | 8dfcce3 | 2020-03-18 19:32:26 +0100 | [diff] [blame] | 2208 | call assert_equal('AAA AAAA AAAAA', g:Sline) |
Bram Moolenaar | 24ebd83 | 2020-03-16 21:25:24 +0100 | [diff] [blame] | 2209 | call assert_equal('"b A', @:) |
| 2210 | |
Girish Palya | 2bacc3e | 2025-03-02 22:55:57 +0100 | [diff] [blame] | 2211 | " When 'wildmenu' is not set, 'noselect' completes first item |
| 2212 | set wildmode=noselect |
| 2213 | call feedkeys(":MyCmd o\t\<C-B>\"\<CR>", 'xt') |
| 2214 | call assert_equal('"MyCmd oneA', @:) |
| 2215 | |
| 2216 | " When 'noselect' is present, do not complete first <tab>. |
| 2217 | set wildmenu |
| 2218 | set wildmode=noselect |
| 2219 | call feedkeys(":MyCmd o\t\<C-B>\"\<CR>", 'xt') |
| 2220 | call assert_equal('"MyCmd o', @:) |
| 2221 | call feedkeys(":MyCmd o\t\t\<C-B>\"\<CR>", 'xt') |
| 2222 | call assert_equal('"MyCmd o', @:) |
| 2223 | call feedkeys(":MyCmd o\t\t\<C-Y>\<C-B>\"\<CR>", 'xt') |
| 2224 | call assert_equal('"MyCmd o', @:) |
| 2225 | |
| 2226 | " When 'full' is present, complete after first <tab>. |
| 2227 | set wildmode=noselect,full |
| 2228 | call feedkeys(":MyCmd o\t\<C-B>\"\<CR>", 'xt') |
| 2229 | call assert_equal('"MyCmd o', @:) |
| 2230 | call feedkeys(":MyCmd o\t\t\<C-B>\"\<CR>", 'xt') |
| 2231 | call assert_equal('"MyCmd oneA', @:) |
| 2232 | call feedkeys(":MyCmd o\t\t\t\<C-B>\"\<CR>", 'xt') |
| 2233 | call assert_equal('"MyCmd oneB', @:) |
| 2234 | call feedkeys(":MyCmd o\t\t\t\<C-Y>\<C-B>\"\<CR>", 'xt') |
| 2235 | call assert_equal('"MyCmd oneB', @:) |
| 2236 | |
| 2237 | " 'noselect' has no effect when 'longest' is present. |
| 2238 | set wildmode=noselect:longest |
| 2239 | call feedkeys(":MyCmd o\t\<C-B>\"\<CR>", 'xt') |
| 2240 | call assert_equal('"MyCmd one', @:) |
| 2241 | |
| 2242 | " Complete 'noselect' value in 'wildmode' option |
| 2243 | set wildmode& |
| 2244 | call feedkeys(":set wildmode=n\t\<C-B>\"\<CR>", 'xt') |
| 2245 | call assert_equal('"set wildmode=noselect', @:) |
| 2246 | call feedkeys(":set wildmode=\t\t\t\t\t\<C-B>\"\<CR>", 'xt') |
| 2247 | call assert_equal('"set wildmode=noselect', @:) |
| 2248 | |
Yegappan Lakshmanan | 4d03d87 | 2022-02-13 11:45:09 +0000 | [diff] [blame] | 2249 | " when using longest completion match, matches shorter than the argument |
| 2250 | " should be ignored (happens with :help) |
| 2251 | set wildmode=longest,full |
Yegappan Lakshmanan | 4d03d87 | 2022-02-13 11:45:09 +0000 | [diff] [blame] | 2252 | call feedkeys(":help a*\t\<C-B>\"\<CR>", 'xt') |
| 2253 | call assert_equal('"help a', @:) |
Yegappan Lakshmanan | 9773db6 | 2022-02-14 11:10:59 +0000 | [diff] [blame] | 2254 | " non existing file |
| 2255 | call feedkeys(":e a1b2y3z4\t\<C-B>\"\<CR>", 'xt') |
| 2256 | call assert_equal('"e a1b2y3z4', @:) |
Yegappan Lakshmanan | 4d03d87 | 2022-02-13 11:45:09 +0000 | [diff] [blame] | 2257 | |
Yegappan Lakshmanan | e3846cf | 2022-02-15 11:35:54 +0000 | [diff] [blame] | 2258 | " Test for longest file name completion with 'fileignorecase' |
| 2259 | " On MS-Windows, file names are case insensitive. |
| 2260 | if has('unix') |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 2261 | call writefile([], 'XTESTfoo', 'D') |
| 2262 | call writefile([], 'Xtestbar', 'D') |
Yegappan Lakshmanan | e3846cf | 2022-02-15 11:35:54 +0000 | [diff] [blame] | 2263 | set nofileignorecase |
| 2264 | call feedkeys(":e XT\<Tab>\<C-B>\"\<CR>", 'xt') |
| 2265 | call assert_equal('"e XTESTfoo', @:) |
| 2266 | call feedkeys(":e Xt\<Tab>\<C-B>\"\<CR>", 'xt') |
| 2267 | call assert_equal('"e Xtestbar', @:) |
| 2268 | set fileignorecase |
| 2269 | call feedkeys(":e XT\<Tab>\<C-B>\"\<CR>", 'xt') |
| 2270 | call assert_equal('"e Xtest', @:) |
| 2271 | call feedkeys(":e Xt\<Tab>\<C-B>\"\<CR>", 'xt') |
| 2272 | call assert_equal('"e Xtest', @:) |
| 2273 | set fileignorecase& |
Yegappan Lakshmanan | e3846cf | 2022-02-15 11:35:54 +0000 | [diff] [blame] | 2274 | endif |
| 2275 | |
Girish Palya | 2bacc3e | 2025-03-02 22:55:57 +0100 | [diff] [blame] | 2276 | " If 'noselect' is present, single item menu should not insert item |
| 2277 | func! T(a, c, p) |
| 2278 | return "oneA" |
| 2279 | endfunc |
| 2280 | command! -nargs=1 -complete=custom,T MyCmd |
| 2281 | set wildmode=noselect,full |
| 2282 | call feedkeys(":MyCmd o\t\<C-B>\"\<CR>", 'xt') |
| 2283 | call assert_equal('"MyCmd o', @:) |
| 2284 | call feedkeys(":MyCmd o\t\t\<C-B>\"\<CR>", 'xt') |
| 2285 | call assert_equal('"MyCmd oneA', @:) |
| 2286 | " 'nowildmenu' should make 'noselect' ineffective |
| 2287 | set nowildmenu |
| 2288 | call feedkeys(":MyCmd o\t\<C-B>\"\<CR>", 'xt') |
| 2289 | call assert_equal('"MyCmd oneA', @:) |
| 2290 | |
Bram Moolenaar | 24ebd83 | 2020-03-16 21:25:24 +0100 | [diff] [blame] | 2291 | %argdelete |
Bram Moolenaar | 578fe94 | 2020-02-27 21:32:51 +0100 | [diff] [blame] | 2292 | delcommand MyCmd |
| 2293 | delfunc T |
Bram Moolenaar | 578fe94 | 2020-02-27 21:32:51 +0100 | [diff] [blame] | 2294 | set wildmode& |
Bram Moolenaar | 24ebd83 | 2020-03-16 21:25:24 +0100 | [diff] [blame] | 2295 | %bwipe! |
Bram Moolenaar | 578fe94 | 2020-02-27 21:32:51 +0100 | [diff] [blame] | 2296 | endfunc |
| 2297 | |
Yegappan Lakshmanan | 9773db6 | 2022-02-14 11:10:59 +0000 | [diff] [blame] | 2298 | func Test_wildmode() |
| 2299 | " Test with utf-8 encoding |
| 2300 | call Wildmode_tests() |
| 2301 | |
| 2302 | " Test with latin1 encoding |
| 2303 | let save_encoding = &encoding |
| 2304 | set encoding=latin1 |
| 2305 | call Wildmode_tests() |
| 2306 | let &encoding = save_encoding |
| 2307 | endfunc |
| 2308 | |
Bram Moolenaar | da6d42c | 2022-03-17 11:46:55 +0000 | [diff] [blame] | 2309 | func Test_custom_complete_autoload() |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 2310 | call mkdir('Xcustdir/autoload', 'pR') |
Bram Moolenaar | da6d42c | 2022-03-17 11:46:55 +0000 | [diff] [blame] | 2311 | let save_rtp = &rtp |
Bram Moolenaar | 61abe7d | 2022-08-30 21:46:08 +0100 | [diff] [blame] | 2312 | exe 'set rtp=' .. getcwd() .. '/Xcustdir' |
Bram Moolenaar | da6d42c | 2022-03-17 11:46:55 +0000 | [diff] [blame] | 2313 | let lines =<< trim END |
| 2314 | func vim8#Complete(a, c, p) |
| 2315 | return "oneA\noneB\noneC" |
| 2316 | endfunc |
| 2317 | END |
Bram Moolenaar | 61abe7d | 2022-08-30 21:46:08 +0100 | [diff] [blame] | 2318 | call writefile(lines, 'Xcustdir/autoload/vim8.vim') |
Bram Moolenaar | da6d42c | 2022-03-17 11:46:55 +0000 | [diff] [blame] | 2319 | |
| 2320 | command -nargs=1 -complete=custom,vim8#Complete MyCmd |
| 2321 | set nowildmenu |
| 2322 | set wildmode=full,list |
| 2323 | call feedkeys(":MyCmd \<C-A>\<C-B>\"\<CR>", 'xt') |
| 2324 | call assert_equal('"MyCmd oneA oneB oneC', @:) |
| 2325 | |
| 2326 | let &rtp = save_rtp |
| 2327 | set wildmode& wildmenu& |
| 2328 | delcommand MyCmd |
Bram Moolenaar | da6d42c | 2022-03-17 11:46:55 +0000 | [diff] [blame] | 2329 | endfunc |
| 2330 | |
Bram Moolenaar | 578fe94 | 2020-02-27 21:32:51 +0100 | [diff] [blame] | 2331 | " Test for interrupting the command-line completion |
| 2332 | func Test_interrupt_compl() |
| 2333 | func F(lead, cmdl, p) |
| 2334 | if a:lead =~ 'tw' |
| 2335 | call interrupt() |
| 2336 | return |
| 2337 | endif |
| 2338 | return "one\ntwo\nthree" |
| 2339 | endfunc |
| 2340 | command -nargs=1 -complete=custom,F Tcmd |
| 2341 | |
| 2342 | set nowildmenu |
| 2343 | set wildmode=full |
| 2344 | let interrupted = 0 |
| 2345 | try |
| 2346 | call feedkeys(":Tcmd tw\<Tab>\<C-B>\"\<CR>", 'xt') |
| 2347 | catch /^Vim:Interrupt$/ |
| 2348 | let interrupted = 1 |
| 2349 | endtry |
| 2350 | call assert_equal(1, interrupted) |
| 2351 | |
Yegappan Lakshmanan | e3846cf | 2022-02-15 11:35:54 +0000 | [diff] [blame] | 2352 | let interrupted = 0 |
| 2353 | try |
| 2354 | call feedkeys(":Tcmd tw\<C-d>\<C-B>\"\<CR>", 'xt') |
| 2355 | catch /^Vim:Interrupt$/ |
| 2356 | let interrupted = 1 |
| 2357 | endtry |
| 2358 | call assert_equal(1, interrupted) |
| 2359 | |
Bram Moolenaar | 578fe94 | 2020-02-27 21:32:51 +0100 | [diff] [blame] | 2360 | delcommand Tcmd |
| 2361 | delfunc F |
| 2362 | set wildmode& |
| 2363 | endfunc |
| 2364 | |
Bram Moolenaar | d30ae2f | 2020-02-29 14:23:58 +0100 | [diff] [blame] | 2365 | " Test for moving the cursor on the : command line |
Bram Moolenaar | 578fe94 | 2020-02-27 21:32:51 +0100 | [diff] [blame] | 2366 | func Test_cmdline_edit() |
Bram Moolenaar | d30ae2f | 2020-02-29 14:23:58 +0100 | [diff] [blame] | 2367 | let str = ":one two\<C-U>" |
| 2368 | let str ..= "one two\<C-W>\<C-W>" |
Bram Moolenaar | 91ffc8a | 2020-03-02 20:54:22 +0100 | [diff] [blame] | 2369 | let str ..= "four\<BS>\<C-H>\<Del>\<kDel>" |
Bram Moolenaar | d30ae2f | 2020-02-29 14:23:58 +0100 | [diff] [blame] | 2370 | let str ..= "\<Left>five\<Right>" |
| 2371 | let str ..= "\<Home>two " |
| 2372 | let str ..= "\<C-Left>one " |
| 2373 | let str ..= "\<C-Right> three" |
| 2374 | let str ..= "\<End>\<S-Left>four " |
| 2375 | let str ..= "\<S-Right> six" |
| 2376 | let str ..= "\<C-B>\"\<C-E> seven\<CR>" |
| 2377 | call feedkeys(str, 'xt') |
| 2378 | call assert_equal("\"one two three four five six seven", @:) |
| 2379 | endfunc |
| 2380 | |
| 2381 | " Test for moving the cursor on the / command line in 'rightleft' mode |
| 2382 | func Test_cmdline_edit_rightleft() |
| 2383 | CheckFeature rightleft |
| 2384 | set rightleft |
| 2385 | set rightleftcmd=search |
| 2386 | let str = "/one two\<C-U>" |
| 2387 | let str ..= "one two\<C-W>\<C-W>" |
Bram Moolenaar | 91ffc8a | 2020-03-02 20:54:22 +0100 | [diff] [blame] | 2388 | let str ..= "four\<BS>\<C-H>\<Del>\<kDel>" |
Bram Moolenaar | d30ae2f | 2020-02-29 14:23:58 +0100 | [diff] [blame] | 2389 | let str ..= "\<Right>five\<Left>" |
| 2390 | let str ..= "\<Home>two " |
| 2391 | let str ..= "\<C-Right>one " |
| 2392 | let str ..= "\<C-Left> three" |
| 2393 | let str ..= "\<End>\<S-Right>four " |
| 2394 | let str ..= "\<S-Left> six" |
| 2395 | let str ..= "\<C-B>\"\<C-E> seven\<CR>" |
| 2396 | call assert_fails("call feedkeys(str, 'xt')", 'E486:') |
| 2397 | call assert_equal("\"one two three four five six seven", @/) |
| 2398 | set rightleftcmd& |
| 2399 | set rightleft& |
| 2400 | endfunc |
| 2401 | |
| 2402 | " Test for using <C-\>e in the command line to evaluate an expression |
| 2403 | func Test_cmdline_expr() |
| 2404 | " Evaluate an expression from the beginning of a command line |
| 2405 | call feedkeys(":abc\<C-B>\<C-\>e\"\\\"hello\"\<CR>\<CR>", 'xt') |
| 2406 | call assert_equal('"hello', @:) |
| 2407 | |
| 2408 | " Use an invalid expression for <C-\>e |
| 2409 | call assert_beeps('call feedkeys(":\<C-\>einvalid\<CR>", "tx")') |
| 2410 | |
| 2411 | " Insert literal <CTRL-\> in the command line |
| 2412 | call feedkeys(":\"e \<C-\>\<C-Y>\<CR>", 'xt') |
| 2413 | call assert_equal("\"e \<C-\>\<C-Y>", @:) |
Bram Moolenaar | 578fe94 | 2020-02-27 21:32:51 +0100 | [diff] [blame] | 2414 | endfunc |
| 2415 | |
Bram Moolenaar | 6046ade | 2022-06-22 13:51:54 +0100 | [diff] [blame] | 2416 | " This was making the insert position negative |
| 2417 | func Test_cmdline_expr_register() |
| 2418 | exe "sil! norm! ?\<C-\>e0\<C-R>0\<Esc>?\<C-\>e0\<CR>" |
| 2419 | endfunc |
| 2420 | |
Bram Moolenaar | 0546d7d | 2020-03-01 16:53:09 +0100 | [diff] [blame] | 2421 | " Test for 'imcmdline' and 'imsearch' |
| 2422 | " This test doesn't actually test the input method functionality. |
| 2423 | func Test_cmdline_inputmethod() |
| 2424 | new |
| 2425 | call setline(1, ['', 'abc', '']) |
| 2426 | set imcmdline |
| 2427 | |
| 2428 | call feedkeys(":\"abc\<CR>", 'xt') |
| 2429 | call assert_equal("\"abc", @:) |
| 2430 | call feedkeys(":\"\<C-^>abc\<C-^>\<CR>", 'xt') |
| 2431 | call assert_equal("\"abc", @:) |
| 2432 | call feedkeys("/abc\<CR>", 'xt') |
| 2433 | call assert_equal([2, 1], [line('.'), col('.')]) |
| 2434 | call feedkeys("/\<C-^>abc\<C-^>\<CR>", 'xt') |
| 2435 | call assert_equal([2, 1], [line('.'), col('.')]) |
| 2436 | |
| 2437 | set imsearch=2 |
| 2438 | call cursor(1, 1) |
| 2439 | call feedkeys("/abc\<CR>", 'xt') |
| 2440 | call assert_equal([2, 1], [line('.'), col('.')]) |
| 2441 | call cursor(1, 1) |
| 2442 | call feedkeys("/\<C-^>abc\<C-^>\<CR>", 'xt') |
| 2443 | call assert_equal([2, 1], [line('.'), col('.')]) |
| 2444 | set imdisable |
| 2445 | call feedkeys("/\<C-^>abc\<C-^>\<CR>", 'xt') |
| 2446 | call assert_equal([2, 1], [line('.'), col('.')]) |
| 2447 | set imdisable& |
| 2448 | set imsearch& |
| 2449 | |
| 2450 | set imcmdline& |
| 2451 | %bwipe! |
| 2452 | endfunc |
| 2453 | |
Bram Moolenaar | 91ffc8a | 2020-03-02 20:54:22 +0100 | [diff] [blame] | 2454 | " Test for using CTRL-_ in the command line with 'allowrevins' |
| 2455 | func Test_cmdline_revins() |
| 2456 | CheckNotMSWindows |
| 2457 | CheckFeature rightleft |
| 2458 | call feedkeys(":\"abc\<c-_>\<cr>", 'xt') |
| 2459 | call assert_equal("\"abc\<c-_>", @:) |
| 2460 | set allowrevins |
| 2461 | call feedkeys(":\"abc\<c-_>xyz\<c-_>\<CR>", 'xt') |
| 2462 | call assert_equal('"abcñèæ', @:) |
| 2463 | set allowrevins& |
| 2464 | endfunc |
| 2465 | |
| 2466 | " Test for typing UTF-8 composing characters in the command line |
| 2467 | func Test_cmdline_composing_chars() |
| 2468 | call feedkeys(":\"\<C-V>u3046\<C-V>u3099\<CR>", 'xt') |
| 2469 | call assert_equal('"ゔ', @:) |
| 2470 | endfunc |
| 2471 | |
Bram Moolenaar | 0e71704 | 2020-04-27 19:29:01 +0200 | [diff] [blame] | 2472 | " test that ";" works to find a match at the start of the first line |
| 2473 | func Test_zero_line_search() |
| 2474 | new |
| 2475 | call setline(1, ["1, pattern", "2, ", "3, pattern"]) |
| 2476 | call cursor(1,1) |
| 2477 | 0;/pattern/d |
| 2478 | call assert_equal(["2, ", "3, pattern"], getline(1,'$')) |
| 2479 | q! |
| 2480 | endfunc |
| 2481 | |
Bram Moolenaar | c8cb883 | 2020-06-18 21:14:30 +0200 | [diff] [blame] | 2482 | func Test_read_shellcmd() |
| 2483 | CheckUnix |
| 2484 | if executable('ls') |
| 2485 | " There should be ls in the $PATH |
| 2486 | call feedkeys(":r! l\<c-a>\<c-b>\"\<cr>", 'tx') |
| 2487 | call assert_match('^"r! .*\<ls\>', @:) |
| 2488 | endif |
| 2489 | |
| 2490 | if executable('rm') |
| 2491 | call feedkeys(":r! ++enc=utf-8 r\<c-a>\<c-b>\"\<cr>", 'tx') |
| 2492 | call assert_notmatch('^"r!.*\<runtest.vim\>', @:) |
| 2493 | call assert_match('^"r!.*\<rm\>', @:) |
Bram Moolenaar | 743d062 | 2020-07-03 18:15:06 +0200 | [diff] [blame] | 2494 | |
| 2495 | call feedkeys(":r ++enc=utf-8 !rm\<c-a>\<c-b>\"\<cr>", 'tx') |
| 2496 | call assert_notmatch('^"r.*\<runtest.vim\>', @:) |
| 2497 | call assert_match('^"r ++enc\S\+ !.*\<rm\>', @:) |
Bram Moolenaar | c8cb883 | 2020-06-18 21:14:30 +0200 | [diff] [blame] | 2498 | endif |
| 2499 | endfunc |
| 2500 | |
Bram Moolenaar | 4b2ce12 | 2020-11-21 21:41:41 +0100 | [diff] [blame] | 2501 | " Test for going up and down the directory tree using 'wildmenu' |
| 2502 | func Test_wildmenu_dirstack() |
| 2503 | CheckUnix |
| 2504 | %bw! |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 2505 | call mkdir('Xwildmenu/dir2/dir3/dir4', 'pR') |
Bram Moolenaar | 3b0d70f | 2022-08-29 22:31:20 +0100 | [diff] [blame] | 2506 | call writefile([], 'Xwildmenu/file1_1.txt') |
| 2507 | call writefile([], 'Xwildmenu/file1_2.txt') |
| 2508 | call writefile([], 'Xwildmenu/dir2/file2_1.txt') |
| 2509 | call writefile([], 'Xwildmenu/dir2/file2_2.txt') |
| 2510 | call writefile([], 'Xwildmenu/dir2/dir3/file3_1.txt') |
| 2511 | call writefile([], 'Xwildmenu/dir2/dir3/file3_2.txt') |
| 2512 | call writefile([], 'Xwildmenu/dir2/dir3/dir4/file4_1.txt') |
| 2513 | call writefile([], 'Xwildmenu/dir2/dir3/dir4/file4_2.txt') |
Bram Moolenaar | 4b2ce12 | 2020-11-21 21:41:41 +0100 | [diff] [blame] | 2514 | set wildmenu |
| 2515 | |
Bram Moolenaar | 3b0d70f | 2022-08-29 22:31:20 +0100 | [diff] [blame] | 2516 | cd Xwildmenu/dir2/dir3/dir4 |
Bram Moolenaar | 4b2ce12 | 2020-11-21 21:41:41 +0100 | [diff] [blame] | 2517 | call feedkeys(":e \<Tab>\<C-B>\"\<CR>", 'xt') |
Yegappan Lakshmanan | b31aec3 | 2022-02-16 12:44:29 +0000 | [diff] [blame] | 2518 | call assert_equal('"e file4_1.txt', @:) |
Bram Moolenaar | 4b2ce12 | 2020-11-21 21:41:41 +0100 | [diff] [blame] | 2519 | call feedkeys(":e \<Tab>\<Up>\<C-B>\"\<CR>", 'xt') |
Yegappan Lakshmanan | b31aec3 | 2022-02-16 12:44:29 +0000 | [diff] [blame] | 2520 | call assert_equal('"e ../dir4/', @:) |
Bram Moolenaar | 4b2ce12 | 2020-11-21 21:41:41 +0100 | [diff] [blame] | 2521 | call feedkeys(":e \<Tab>\<Up>\<Up>\<C-B>\"\<CR>", 'xt') |
Yegappan Lakshmanan | b31aec3 | 2022-02-16 12:44:29 +0000 | [diff] [blame] | 2522 | call assert_equal('"e ../../dir3/', @:) |
| 2523 | call feedkeys(":e \<Tab>\<Up>\<Up>\<Up>\<C-B>\"\<CR>", 'xt') |
| 2524 | call assert_equal('"e ../../../dir2/', @:) |
Bram Moolenaar | 4b2ce12 | 2020-11-21 21:41:41 +0100 | [diff] [blame] | 2525 | call feedkeys(":e \<Tab>\<Up>\<Up>\<Down>\<C-B>\"\<CR>", 'xt') |
Yegappan Lakshmanan | b31aec3 | 2022-02-16 12:44:29 +0000 | [diff] [blame] | 2526 | call assert_equal('"e ../../dir3/dir4/', @:) |
Bram Moolenaar | 4b2ce12 | 2020-11-21 21:41:41 +0100 | [diff] [blame] | 2527 | call feedkeys(":e \<Tab>\<Up>\<Up>\<Down>\<Down>\<C-B>\"\<CR>", 'xt') |
Yegappan Lakshmanan | b31aec3 | 2022-02-16 12:44:29 +0000 | [diff] [blame] | 2528 | call assert_equal('"e ../../dir3/dir4/file4_1.txt', @:) |
Bram Moolenaar | 4b2ce12 | 2020-11-21 21:41:41 +0100 | [diff] [blame] | 2529 | cd - |
Bram Moolenaar | 3b0d70f | 2022-08-29 22:31:20 +0100 | [diff] [blame] | 2530 | call feedkeys(":e Xwildmenu/\<Tab>\<Down>\<Down>\<Down>\<C-B>\"\<CR>", 'xt') |
| 2531 | call assert_equal('"e Xwildmenu/dir2/dir3/dir4/file4_1.txt', @:) |
Yegappan Lakshmanan | b31aec3 | 2022-02-16 12:44:29 +0000 | [diff] [blame] | 2532 | |
Bram Moolenaar | 4b2ce12 | 2020-11-21 21:41:41 +0100 | [diff] [blame] | 2533 | set wildmenu& |
| 2534 | endfunc |
| 2535 | |
obcat | 71c6f7a | 2021-05-13 20:23:10 +0200 | [diff] [blame] | 2536 | " Test for recalling newer or older cmdline from history with <Up>, <Down>, |
Yegappan Lakshmanan | 155b088 | 2022-03-17 13:03:09 +0000 | [diff] [blame] | 2537 | " <S-Up>, <S-Down>, <PageUp>, <PageDown>, <kPageUp>, <kPageDown>, <C-p>, or |
| 2538 | " <C-n>. |
obcat | 71c6f7a | 2021-05-13 20:23:10 +0200 | [diff] [blame] | 2539 | func Test_recalling_cmdline() |
| 2540 | CheckFeature cmdline_hist |
| 2541 | |
| 2542 | let g:cmdlines = [] |
| 2543 | cnoremap <Plug>(save-cmdline) <Cmd>let g:cmdlines += [getcmdline()]<CR> |
| 2544 | |
| 2545 | let histories = [ |
Yegappan Lakshmanan | 155b088 | 2022-03-17 13:03:09 +0000 | [diff] [blame] | 2546 | \ #{name: 'cmd', enter: ':', exit: "\<Esc>"}, |
| 2547 | \ #{name: 'search', enter: '/', exit: "\<Esc>"}, |
| 2548 | \ #{name: 'expr', enter: ":\<C-r>=", exit: "\<Esc>\<Esc>"}, |
| 2549 | \ #{name: 'input', enter: ":call input('')\<CR>", exit: "\<CR>"}, |
obcat | 71c6f7a | 2021-05-13 20:23:10 +0200 | [diff] [blame] | 2550 | "\ TODO: {'name': 'debug', ...} |
| 2551 | \] |
| 2552 | let keypairs = [ |
Yegappan Lakshmanan | 155b088 | 2022-03-17 13:03:09 +0000 | [diff] [blame] | 2553 | \ #{older: "\<Up>", newer: "\<Down>", prefixmatch: v:true}, |
| 2554 | \ #{older: "\<S-Up>", newer: "\<S-Down>", prefixmatch: v:false}, |
| 2555 | \ #{older: "\<PageUp>", newer: "\<PageDown>", prefixmatch: v:false}, |
| 2556 | \ #{older: "\<kPageUp>", newer: "\<kPageDown>", prefixmatch: v:false}, |
| 2557 | \ #{older: "\<C-p>", newer: "\<C-n>", prefixmatch: v:false}, |
obcat | 71c6f7a | 2021-05-13 20:23:10 +0200 | [diff] [blame] | 2558 | \] |
| 2559 | let prefix = 'vi' |
| 2560 | for h in histories |
| 2561 | call histadd(h.name, 'vim') |
| 2562 | call histadd(h.name, 'virtue') |
| 2563 | call histadd(h.name, 'Virgo') |
| 2564 | call histadd(h.name, 'vogue') |
| 2565 | call histadd(h.name, 'emacs') |
| 2566 | for k in keypairs |
| 2567 | let g:cmdlines = [] |
| 2568 | let keyseqs = h.enter |
| 2569 | \ .. prefix |
| 2570 | \ .. repeat(k.older .. "\<Plug>(save-cmdline)", 2) |
| 2571 | \ .. repeat(k.newer .. "\<Plug>(save-cmdline)", 2) |
| 2572 | \ .. h.exit |
| 2573 | call feedkeys(keyseqs, 'xt') |
| 2574 | call histdel(h.name, -1) " delete the history added by feedkeys above |
| 2575 | let expect = k.prefixmatch |
| 2576 | \ ? ['virtue', 'vim', 'virtue', prefix] |
| 2577 | \ : ['emacs', 'vogue', 'emacs', prefix] |
| 2578 | call assert_equal(expect, g:cmdlines) |
| 2579 | endfor |
| 2580 | endfor |
| 2581 | |
| 2582 | unlet g:cmdlines |
| 2583 | cunmap <Plug>(save-cmdline) |
| 2584 | endfunc |
| 2585 | |
Bram Moolenaar | 847fe7d | 2021-05-15 13:19:16 +0200 | [diff] [blame] | 2586 | func Test_cmd_map_cmdlineChanged() |
| 2587 | let g:log = [] |
| 2588 | cnoremap <F1> l<Cmd><CR>s |
zeertzjq | 094dd15 | 2023-06-15 22:51:57 +0100 | [diff] [blame] | 2589 | augroup test_CmdlineChanged |
Bram Moolenaar | 847fe7d | 2021-05-15 13:19:16 +0200 | [diff] [blame] | 2590 | autocmd! |
| 2591 | autocmd CmdlineChanged : let g:log += [getcmdline()] |
| 2592 | augroup END |
| 2593 | |
| 2594 | call feedkeys(":\<F1>\<CR>", 'xt') |
| 2595 | call assert_equal(['l', 'ls'], g:log) |
| 2596 | |
Bram Moolenaar | 796139a | 2021-05-18 21:38:45 +0200 | [diff] [blame] | 2597 | let @b = 'b' |
| 2598 | cnoremap <F1> a<C-R>b |
| 2599 | let g:log = [] |
| 2600 | call feedkeys(":\<F1>\<CR>", 'xt') |
| 2601 | call assert_equal(['a', 'ab'], g:log) |
| 2602 | |
Bram Moolenaar | 847fe7d | 2021-05-15 13:19:16 +0200 | [diff] [blame] | 2603 | unlet g:log |
| 2604 | cunmap <F1> |
zeertzjq | 094dd15 | 2023-06-15 22:51:57 +0100 | [diff] [blame] | 2605 | augroup test_CmdlineChanged |
Bram Moolenaar | 847fe7d | 2021-05-15 13:19:16 +0200 | [diff] [blame] | 2606 | autocmd! |
| 2607 | augroup END |
zeertzjq | 094dd15 | 2023-06-15 22:51:57 +0100 | [diff] [blame] | 2608 | augroup! test_CmdlineChanged |
Bram Moolenaar | 847fe7d | 2021-05-15 13:19:16 +0200 | [diff] [blame] | 2609 | endfunc |
| 2610 | |
Yegappan Lakshmanan | 46aa6f9 | 2021-05-19 17:15:04 +0200 | [diff] [blame] | 2611 | " Test for the 'suffixes' option |
| 2612 | func Test_suffixes_opt() |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 2613 | call writefile([], 'Xsuffile', 'D') |
| 2614 | call writefile([], 'Xsuffile.c', 'D') |
| 2615 | call writefile([], 'Xsuffile.o', 'D') |
Yegappan Lakshmanan | 46aa6f9 | 2021-05-19 17:15:04 +0200 | [diff] [blame] | 2616 | set suffixes= |
Bram Moolenaar | 61abe7d | 2022-08-30 21:46:08 +0100 | [diff] [blame] | 2617 | call feedkeys(":e Xsuffi*\<C-A>\<C-B>\"\<CR>", 'xt') |
| 2618 | call assert_equal('"e Xsuffile Xsuffile.c Xsuffile.o', @:) |
| 2619 | call feedkeys(":e Xsuffi*\<Tab>\<Tab>\<C-B>\"\<CR>", 'xt') |
| 2620 | call assert_equal('"e Xsuffile.c', @:) |
Yegappan Lakshmanan | 46aa6f9 | 2021-05-19 17:15:04 +0200 | [diff] [blame] | 2621 | set suffixes=.c |
Bram Moolenaar | 61abe7d | 2022-08-30 21:46:08 +0100 | [diff] [blame] | 2622 | call feedkeys(":e Xsuffi*\<C-A>\<C-B>\"\<CR>", 'xt') |
| 2623 | call assert_equal('"e Xsuffile Xsuffile.o Xsuffile.c', @:) |
| 2624 | call feedkeys(":e Xsuffi*\<Tab>\<Tab>\<C-B>\"\<CR>", 'xt') |
| 2625 | call assert_equal('"e Xsuffile.o', @:) |
Yegappan Lakshmanan | 46aa6f9 | 2021-05-19 17:15:04 +0200 | [diff] [blame] | 2626 | set suffixes=,, |
Bram Moolenaar | 61abe7d | 2022-08-30 21:46:08 +0100 | [diff] [blame] | 2627 | call feedkeys(":e Xsuffi*\<C-A>\<C-B>\"\<CR>", 'xt') |
| 2628 | call assert_equal('"e Xsuffile.c Xsuffile.o Xsuffile', @:) |
| 2629 | call feedkeys(":e Xsuffi*\<Tab>\<Tab>\<C-B>\"\<CR>", 'xt') |
| 2630 | call assert_equal('"e Xsuffile.o', @:) |
Yegappan Lakshmanan | 46aa6f9 | 2021-05-19 17:15:04 +0200 | [diff] [blame] | 2631 | set suffixes& |
Yegappan Lakshmanan | 9773db6 | 2022-02-14 11:10:59 +0000 | [diff] [blame] | 2632 | " Test for getcompletion() with different patterns |
Bram Moolenaar | 61abe7d | 2022-08-30 21:46:08 +0100 | [diff] [blame] | 2633 | call assert_equal(['Xsuffile', 'Xsuffile.c', 'Xsuffile.o'], getcompletion('Xsuffile', 'file')) |
| 2634 | call assert_equal(['Xsuffile'], getcompletion('Xsuffile$', 'file')) |
Yegappan Lakshmanan | 46aa6f9 | 2021-05-19 17:15:04 +0200 | [diff] [blame] | 2635 | endfunc |
Bram Moolenaar | 847fe7d | 2021-05-15 13:19:16 +0200 | [diff] [blame] | 2636 | |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2637 | " Test for using a popup menu for the command line completion matches |
| 2638 | " (wildoptions=pum) |
| 2639 | func Test_wildmenu_pum() |
Drew Vogel | ea67ba7 | 2025-05-07 22:05:17 +0200 | [diff] [blame] | 2640 | CheckScreendump |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2641 | CheckRunVimInTerminal |
| 2642 | |
| 2643 | let commands =<< trim [CODE] |
| 2644 | set wildmenu |
| 2645 | set wildoptions=pum |
| 2646 | set shm+=I |
| 2647 | set noruler |
| 2648 | set noshowcmd |
Yegappan Lakshmanan | 560dff4 | 2022-02-10 19:52:10 +0000 | [diff] [blame] | 2649 | |
| 2650 | func CmdCompl(a, b, c) |
| 2651 | return repeat(['aaaa'], 120) |
| 2652 | endfunc |
| 2653 | command -nargs=* -complete=customlist,CmdCompl Tcmd |
Bram Moolenaar | 481acb1 | 2022-02-11 18:51:45 +0000 | [diff] [blame] | 2654 | |
| 2655 | func MyStatusLine() abort |
| 2656 | return 'status' |
| 2657 | endfunc |
| 2658 | func SetupStatusline() |
| 2659 | set statusline=%!MyStatusLine() |
| 2660 | set laststatus=2 |
| 2661 | endfunc |
Bram Moolenaar | e4835bf | 2022-02-14 19:17:53 +0000 | [diff] [blame] | 2662 | |
| 2663 | func MyTabLine() |
| 2664 | return 'my tab line' |
| 2665 | endfunc |
| 2666 | func SetupTabline() |
| 2667 | set statusline= |
| 2668 | set tabline=%!MyTabLine() |
| 2669 | set showtabline=2 |
| 2670 | endfunc |
Bram Moolenaar | 5c52be4 | 2022-02-27 14:28:31 +0000 | [diff] [blame] | 2671 | |
| 2672 | func DoFeedKeys() |
| 2673 | let &wildcharm = char2nr("\t") |
| 2674 | call feedkeys(":edit $VIMRUNTIME/\<Tab>\<Left>\<C-U>ab\<Tab>") |
| 2675 | endfunc |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2676 | [CODE] |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 2677 | call writefile(commands, 'Xtest', 'D') |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2678 | |
| 2679 | let buf = RunVimInTerminal('-S Xtest', #{rows: 10}) |
| 2680 | |
| 2681 | call term_sendkeys(buf, ":sign \<Tab>") |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2682 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_01', {}) |
| 2683 | |
Yegappan Lakshmanan | 560dff4 | 2022-02-10 19:52:10 +0000 | [diff] [blame] | 2684 | " going down the popup menu using <Down> |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2685 | call term_sendkeys(buf, "\<Down>\<Down>") |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2686 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_02', {}) |
| 2687 | |
Yegappan Lakshmanan | 560dff4 | 2022-02-10 19:52:10 +0000 | [diff] [blame] | 2688 | " going down the popup menu using <C-N> |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2689 | call term_sendkeys(buf, "\<C-N>") |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2690 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_03', {}) |
| 2691 | |
Yegappan Lakshmanan | 560dff4 | 2022-02-10 19:52:10 +0000 | [diff] [blame] | 2692 | " going up the popup menu using <C-P> |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2693 | call term_sendkeys(buf, "\<C-P>") |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2694 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_04', {}) |
| 2695 | |
Yegappan Lakshmanan | 560dff4 | 2022-02-10 19:52:10 +0000 | [diff] [blame] | 2696 | " going up the popup menu using <Up> |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2697 | call term_sendkeys(buf, "\<Up>") |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2698 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_05', {}) |
| 2699 | |
| 2700 | " pressing <C-E> should end completion and go back to the original match |
| 2701 | call term_sendkeys(buf, "\<C-E>") |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2702 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_06', {}) |
| 2703 | |
| 2704 | " pressing <C-Y> should select the current match and end completion |
| 2705 | call term_sendkeys(buf, "\<Tab>\<C-P>\<C-P>\<C-Y>") |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2706 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_07', {}) |
| 2707 | |
| 2708 | " With 'wildmode' set to 'longest,full', completing a match should display |
| 2709 | " the longest match, the wildmenu should not be displayed. |
| 2710 | call term_sendkeys(buf, ":\<C-U>set wildmode=longest,full\<CR>") |
| 2711 | call TermWait(buf) |
| 2712 | call term_sendkeys(buf, ":sign u\<Tab>") |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2713 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_08', {}) |
| 2714 | |
| 2715 | " pressing <Tab> should display the wildmenu |
| 2716 | call term_sendkeys(buf, "\<Tab>") |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2717 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_09', {}) |
| 2718 | |
| 2719 | " pressing <Tab> second time should select the next entry in the menu |
| 2720 | call term_sendkeys(buf, "\<Tab>") |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2721 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_10', {}) |
| 2722 | |
| 2723 | call term_sendkeys(buf, ":\<C-U>set wildmode=full\<CR>") |
Yegappan Lakshmanan | 560dff4 | 2022-02-10 19:52:10 +0000 | [diff] [blame] | 2724 | " showing popup menu in different columns in the cmdline |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2725 | call term_sendkeys(buf, ":sign define \<Tab>") |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2726 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_11', {}) |
| 2727 | |
| 2728 | call term_sendkeys(buf, " \<Tab>") |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2729 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_12', {}) |
| 2730 | |
| 2731 | call term_sendkeys(buf, " \<Tab>") |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2732 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_13', {}) |
| 2733 | |
| 2734 | " Directory name completion |
Dominique Pelle | febe138 | 2022-09-14 12:51:49 +0100 | [diff] [blame] | 2735 | call mkdir('Xnamedir/XdirA/XdirB', 'pR') |
Bram Moolenaar | 61abe7d | 2022-08-30 21:46:08 +0100 | [diff] [blame] | 2736 | call writefile([], 'Xnamedir/XfileA') |
| 2737 | call writefile([], 'Xnamedir/XdirA/XfileB') |
| 2738 | call writefile([], 'Xnamedir/XdirA/XdirB/XfileC') |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2739 | |
Bram Moolenaar | 61abe7d | 2022-08-30 21:46:08 +0100 | [diff] [blame] | 2740 | call term_sendkeys(buf, "\<C-U>e Xnamedi\<Tab>\<Tab>") |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2741 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_14', {}) |
| 2742 | |
| 2743 | " Pressing <Right> on a directory name should go into that directory |
| 2744 | call term_sendkeys(buf, "\<Right>") |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2745 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_15', {}) |
| 2746 | |
| 2747 | " Pressing <Left> on a directory name should go to the parent directory |
| 2748 | call term_sendkeys(buf, "\<Left>") |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2749 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_16', {}) |
| 2750 | |
| 2751 | " Pressing <C-A> when the popup menu is displayed should list all the |
Yegappan Lakshmanan | 560dff4 | 2022-02-10 19:52:10 +0000 | [diff] [blame] | 2752 | " matches but the popup menu should still remain |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2753 | call term_sendkeys(buf, "\<C-U>sign \<Tab>\<C-A>") |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2754 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_17', {}) |
| 2755 | |
| 2756 | " Pressing <C-D> when the popup menu is displayed should remove the popup |
| 2757 | " menu |
| 2758 | call term_sendkeys(buf, "\<C-U>sign \<Tab>\<C-D>") |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2759 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_18', {}) |
| 2760 | |
| 2761 | " Pressing <S-Tab> should open the popup menu with the last entry selected |
| 2762 | call term_sendkeys(buf, "\<C-U>\<CR>:sign \<S-Tab>\<C-P>") |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2763 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_19', {}) |
| 2764 | |
| 2765 | " Pressing <Esc> should close the popup menu and cancel the cmd line |
| 2766 | call term_sendkeys(buf, "\<C-U>\<CR>:sign \<Tab>\<Esc>") |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2767 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_20', {}) |
| 2768 | |
| 2769 | " Typing a character when the popup is open, should close the popup |
| 2770 | call term_sendkeys(buf, ":sign \<Tab>x") |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2771 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_21', {}) |
| 2772 | |
| 2773 | " When the popup is open, entering the cmdline window should close the popup |
| 2774 | call term_sendkeys(buf, "\<C-U>sign \<Tab>\<C-F>") |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2775 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_22', {}) |
| 2776 | call term_sendkeys(buf, ":q\<CR>") |
| 2777 | |
| 2778 | " After the last popup menu item, <C-N> should show the original string |
| 2779 | call term_sendkeys(buf, ":sign u\<Tab>\<C-N>\<C-N>") |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2780 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_23', {}) |
| 2781 | |
| 2782 | " Use the popup menu for the command name |
| 2783 | call term_sendkeys(buf, "\<C-U>bu\<Tab>") |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2784 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_24', {}) |
| 2785 | |
| 2786 | " Pressing the left arrow should remove the popup menu |
| 2787 | call term_sendkeys(buf, "\<Left>\<Left>") |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2788 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_25', {}) |
| 2789 | |
| 2790 | " Pressing <BS> should remove the popup menu and erase the last character |
| 2791 | call term_sendkeys(buf, "\<C-E>\<C-U>sign \<Tab>\<BS>") |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2792 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_26', {}) |
| 2793 | |
| 2794 | " Pressing <C-W> should remove the popup menu and erase the previous word |
| 2795 | call term_sendkeys(buf, "\<C-E>\<C-U>sign \<Tab>\<C-W>") |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2796 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_27', {}) |
| 2797 | |
| 2798 | " Pressing <C-U> should remove the popup menu and erase the entire line |
| 2799 | call term_sendkeys(buf, "\<C-E>\<C-U>sign \<Tab>\<C-U>") |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2800 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_28', {}) |
| 2801 | |
| 2802 | " Using <C-E> to cancel the popup menu and then pressing <Up> should recall |
| 2803 | " the cmdline from history |
| 2804 | call term_sendkeys(buf, "sign xyz\<Esc>:sign \<Tab>\<C-E>\<Up>") |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2805 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_29', {}) |
| 2806 | |
Bram Moolenaar | 73a16c2 | 2022-02-08 17:40:36 +0000 | [diff] [blame] | 2807 | " Check "list" still works |
| 2808 | call term_sendkeys(buf, "\<C-U>set wildmode=longest,list\<CR>") |
| 2809 | call term_sendkeys(buf, ":cn\<Tab>") |
Bram Moolenaar | 73a16c2 | 2022-02-08 17:40:36 +0000 | [diff] [blame] | 2810 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_30', {}) |
| 2811 | call term_sendkeys(buf, "s") |
Bram Moolenaar | 73a16c2 | 2022-02-08 17:40:36 +0000 | [diff] [blame] | 2812 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_31', {}) |
| 2813 | |
rbtnn | 68cc2b8 | 2022-02-09 11:55:47 +0000 | [diff] [blame] | 2814 | " Tests a directory name contained full-width characters. |
Dominique Pelle | febe138 | 2022-09-14 12:51:49 +0100 | [diff] [blame] | 2815 | call mkdir('Xnamedir/あいう', 'p') |
Bram Moolenaar | 61abe7d | 2022-08-30 21:46:08 +0100 | [diff] [blame] | 2816 | call writefile([], 'Xnamedir/あいう/abc') |
| 2817 | call writefile([], 'Xnamedir/あいう/xyz') |
| 2818 | call writefile([], 'Xnamedir/あいう/123') |
rbtnn | 68cc2b8 | 2022-02-09 11:55:47 +0000 | [diff] [blame] | 2819 | |
| 2820 | call term_sendkeys(buf, "\<C-U>set wildmode&\<CR>") |
Bram Moolenaar | 61abe7d | 2022-08-30 21:46:08 +0100 | [diff] [blame] | 2821 | call term_sendkeys(buf, ":\<C-U>e Xnamedir/あいう/\<Tab>") |
rbtnn | 68cc2b8 | 2022-02-09 11:55:47 +0000 | [diff] [blame] | 2822 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_32', {}) |
| 2823 | |
Yegappan Lakshmanan | 560dff4 | 2022-02-10 19:52:10 +0000 | [diff] [blame] | 2824 | " Pressing <C-A> when the popup menu is displayed should list all the |
| 2825 | " matches and pressing a key after that should remove the popup menu |
| 2826 | call term_sendkeys(buf, "\<C-U>set wildmode=full\<CR>") |
| 2827 | call term_sendkeys(buf, ":sign \<Tab>\<C-A>x") |
| 2828 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_33', {}) |
| 2829 | |
| 2830 | " Pressing <C-A> when the popup menu is displayed should list all the |
| 2831 | " matches and pressing <Left> after that should move the cursor |
| 2832 | call term_sendkeys(buf, "\<C-U>abc\<Esc>") |
| 2833 | call term_sendkeys(buf, ":sign \<Tab>\<C-A>\<Left>") |
| 2834 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_34', {}) |
| 2835 | |
| 2836 | " When <C-A> displays a lot of matches (screen scrolls), all the matches |
| 2837 | " should be displayed correctly on the screen. |
| 2838 | call term_sendkeys(buf, "\<End>\<C-U>Tcmd \<Tab>\<C-A>\<Left>\<Left>") |
| 2839 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_35', {}) |
| 2840 | |
| 2841 | " After using <C-A> to expand all the filename matches, pressing <Up> |
| 2842 | " should not open the popup menu again. |
Bram Moolenaar | 61abe7d | 2022-08-30 21:46:08 +0100 | [diff] [blame] | 2843 | call term_sendkeys(buf, "\<C-E>\<C-U>:cd Xnamedir/XdirA\<CR>") |
Yegappan Lakshmanan | 560dff4 | 2022-02-10 19:52:10 +0000 | [diff] [blame] | 2844 | call term_sendkeys(buf, ":e \<Tab>\<C-A>\<Up>") |
| 2845 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_36', {}) |
| 2846 | call term_sendkeys(buf, "\<C-E>\<C-U>:cd -\<CR>") |
| 2847 | |
| 2848 | " After using <C-A> to expand all the matches, pressing <S-Tab> used to |
| 2849 | " crash Vim |
| 2850 | call term_sendkeys(buf, ":sign \<Tab>\<C-A>\<S-Tab>") |
| 2851 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_37', {}) |
| 2852 | |
Bram Moolenaar | 414acd3 | 2022-02-10 21:09:45 +0000 | [diff] [blame] | 2853 | " After removing the pum the command line is redrawn |
| 2854 | call term_sendkeys(buf, ":edit foo\<CR>") |
| 2855 | call term_sendkeys(buf, ":edit bar\<CR>") |
| 2856 | call term_sendkeys(buf, ":ls\<CR>") |
| 2857 | call term_sendkeys(buf, ":com\<Tab> ") |
| 2858 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_38', {}) |
Bram Moolenaar | 481acb1 | 2022-02-11 18:51:45 +0000 | [diff] [blame] | 2859 | call term_sendkeys(buf, "\<C-U>\<CR>") |
| 2860 | |
| 2861 | " Esc still works to abort the command when 'statusline' is set |
| 2862 | call term_sendkeys(buf, ":call SetupStatusline()\<CR>") |
| 2863 | call term_sendkeys(buf, ":si\<Tab>") |
| 2864 | call term_sendkeys(buf, "\<Esc>") |
| 2865 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_39', {}) |
Bram Moolenaar | 414acd3 | 2022-02-10 21:09:45 +0000 | [diff] [blame] | 2866 | |
Bram Moolenaar | e4835bf | 2022-02-14 19:17:53 +0000 | [diff] [blame] | 2867 | " Esc still works to abort the command when 'tabline' is set |
| 2868 | call term_sendkeys(buf, ":call SetupTabline()\<CR>") |
| 2869 | call term_sendkeys(buf, ":si\<Tab>") |
| 2870 | call term_sendkeys(buf, "\<Esc>") |
| 2871 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_40', {}) |
| 2872 | |
Bram Moolenaar | 5c52be4 | 2022-02-27 14:28:31 +0000 | [diff] [blame] | 2873 | " popup is cleared also when 'lazyredraw' is set |
| 2874 | call term_sendkeys(buf, ":set showtabline=1 laststatus=1 lazyredraw\<CR>") |
| 2875 | call term_sendkeys(buf, ":call DoFeedKeys()\<CR>") |
| 2876 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_41', {}) |
| 2877 | call term_sendkeys(buf, "\<Esc>") |
| 2878 | |
Yegappan Lakshmanan | 5cffa8d | 2022-03-16 13:33:53 +0000 | [diff] [blame] | 2879 | " Pressing <PageDown> should scroll the menu downward |
| 2880 | call term_sendkeys(buf, ":sign \<Tab>\<PageDown>") |
| 2881 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_42', {}) |
| 2882 | call term_sendkeys(buf, "\<PageDown>") |
| 2883 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_43', {}) |
| 2884 | call term_sendkeys(buf, "\<PageDown>") |
| 2885 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_44', {}) |
| 2886 | call term_sendkeys(buf, "\<PageDown>") |
| 2887 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_45', {}) |
| 2888 | call term_sendkeys(buf, "\<C-U>sign \<Tab>\<Down>\<Down>\<PageDown>") |
| 2889 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_46', {}) |
| 2890 | |
| 2891 | " Pressing <PageUp> should scroll the menu upward |
| 2892 | call term_sendkeys(buf, "\<C-U>sign \<Tab>\<PageUp>") |
| 2893 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_47', {}) |
| 2894 | call term_sendkeys(buf, "\<PageUp>") |
| 2895 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_48', {}) |
| 2896 | call term_sendkeys(buf, "\<PageUp>") |
| 2897 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_49', {}) |
| 2898 | call term_sendkeys(buf, "\<PageUp>") |
| 2899 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_50', {}) |
| 2900 | |
Yee Cheng Chin | 209ec90 | 2023-10-17 10:56:25 +0200 | [diff] [blame] | 2901 | " pressing <C-E> to end completion should work in middle of the line too |
| 2902 | call term_sendkeys(buf, "\<Esc>:set wildchazz\<Left>\<Left>\<Tab>") |
| 2903 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_51', {}) |
| 2904 | call term_sendkeys(buf, "\<C-E>") |
| 2905 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_52', {}) |
| 2906 | |
| 2907 | " pressing <C-Y> should select the current match and end completion |
| 2908 | call term_sendkeys(buf, "\<Esc>:set wildchazz\<Left>\<Left>\<Tab>\<C-Y>") |
| 2909 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_53', {}) |
| 2910 | |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2911 | call term_sendkeys(buf, "\<C-U>\<CR>") |
| 2912 | call StopVimInTerminal(buf) |
Yegappan Lakshmanan | 3908ef5 | 2022-02-08 12:08:07 +0000 | [diff] [blame] | 2913 | endfunc |
| 2914 | |
Yegappan Lakshmanan | 560dff4 | 2022-02-10 19:52:10 +0000 | [diff] [blame] | 2915 | " Test for wildmenumode() with the cmdline popup menu |
| 2916 | func Test_wildmenumode_with_pum() |
| 2917 | set wildmenu |
| 2918 | set wildoptions=pum |
| 2919 | cnoremap <expr> <F2> wildmenumode() |
| 2920 | call feedkeys(":sign \<Tab>\<F2>\<F2>\<C-B>\"\<CR>", 'xt') |
| 2921 | call assert_equal('"sign define10', @:) |
| 2922 | call feedkeys(":sign \<Tab>\<C-A>\<F2>\<C-B>\"\<CR>", 'xt') |
| 2923 | call assert_equal('"sign define jump list place undefine unplace0', @:) |
| 2924 | call feedkeys(":sign \<Tab>\<C-E>\<F2>\<C-B>\"\<CR>", 'xt') |
| 2925 | call assert_equal('"sign 0', @:) |
| 2926 | call feedkeys(":sign \<Tab>\<C-Y>\<F2>\<C-B>\"\<CR>", 'xt') |
| 2927 | call assert_equal('"sign define0', @:) |
| 2928 | set nowildmenu wildoptions& |
| 2929 | cunmap <F2> |
| 2930 | endfunc |
| 2931 | |
Bram Moolenaar | 11a57df | 2022-04-11 19:38:56 +0100 | [diff] [blame] | 2932 | func Test_wildmenu_with_pum_foldexpr() |
Drew Vogel | ea67ba7 | 2025-05-07 22:05:17 +0200 | [diff] [blame] | 2933 | CheckScreendump |
Bram Moolenaar | 11a57df | 2022-04-11 19:38:56 +0100 | [diff] [blame] | 2934 | CheckRunVimInTerminal |
| 2935 | |
| 2936 | let lines =<< trim END |
| 2937 | call setline(1, ['folded one', 'folded two', 'some more text']) |
| 2938 | func MyFoldText() |
| 2939 | return 'foo' |
| 2940 | endfunc |
| 2941 | set foldtext=MyFoldText() wildoptions=pum |
| 2942 | normal ggzfj |
| 2943 | END |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 2944 | call writefile(lines, 'Xpumfold', 'D') |
Bram Moolenaar | 11a57df | 2022-04-11 19:38:56 +0100 | [diff] [blame] | 2945 | let buf = RunVimInTerminal('-S Xpumfold', #{rows: 10}) |
| 2946 | call term_sendkeys(buf, ":set\<Tab>") |
| 2947 | call VerifyScreenDump(buf, 'Test_wildmenu_with_pum_foldexpr_1', {}) |
| 2948 | |
| 2949 | call term_sendkeys(buf, "\<Esc>") |
| 2950 | call VerifyScreenDump(buf, 'Test_wildmenu_with_pum_foldexpr_2', {}) |
| 2951 | |
| 2952 | call StopVimInTerminal(buf) |
Bram Moolenaar | 11a57df | 2022-04-11 19:38:56 +0100 | [diff] [blame] | 2953 | endfunc |
| 2954 | |
Yegappan Lakshmanan | 1104a6d | 2022-03-31 12:34:15 +0100 | [diff] [blame] | 2955 | " Test for opening the cmdline completion popup menu from the terminal window. |
| 2956 | " The popup menu should be positioned correctly over the status line of the |
| 2957 | " bottom-most window. |
| 2958 | func Test_wildmenu_pum_from_terminal() |
Drew Vogel | ea67ba7 | 2025-05-07 22:05:17 +0200 | [diff] [blame] | 2959 | CheckScreendump |
Yegappan Lakshmanan | 1104a6d | 2022-03-31 12:34:15 +0100 | [diff] [blame] | 2960 | CheckRunVimInTerminal |
| 2961 | let python = PythonProg() |
| 2962 | call CheckPython(python) |
| 2963 | |
| 2964 | %bw! |
| 2965 | let cmds = ['set wildmenu wildoptions=pum'] |
| 2966 | let pcmd = python .. ' -c "import sys; sys.stdout.write(sys.stdin.read())"' |
| 2967 | call add(cmds, "call term_start('" .. pcmd .. "')") |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 2968 | call writefile(cmds, 'Xtest', 'D') |
Yegappan Lakshmanan | 1104a6d | 2022-03-31 12:34:15 +0100 | [diff] [blame] | 2969 | let buf = RunVimInTerminal('-S Xtest', #{rows: 10}) |
| 2970 | call term_sendkeys(buf, "\r\r\r") |
| 2971 | call term_wait(buf) |
| 2972 | call term_sendkeys(buf, "\<C-W>:sign \<Tab>") |
| 2973 | call term_wait(buf) |
| 2974 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_term_01', {}) |
| 2975 | call term_wait(buf) |
| 2976 | call StopVimInTerminal(buf) |
Yegappan Lakshmanan | 1104a6d | 2022-03-31 12:34:15 +0100 | [diff] [blame] | 2977 | endfunc |
| 2978 | |
Yee Cheng Chin | 8f4fb00 | 2023-10-17 10:06:56 +0200 | [diff] [blame] | 2979 | func Test_wildmenu_pum_odd_wildchar() |
Drew Vogel | ea67ba7 | 2025-05-07 22:05:17 +0200 | [diff] [blame] | 2980 | CheckScreendump |
Bram Moolenaar | b9603f6 | 2022-12-08 15:44:22 +0000 | [diff] [blame] | 2981 | CheckRunVimInTerminal |
| 2982 | |
Yee Cheng Chin | 8f4fb00 | 2023-10-17 10:06:56 +0200 | [diff] [blame] | 2983 | " Test odd wildchar interactions with pum. Make sure they behave properly |
| 2984 | " and don't lead to memory corruption due to improperly cleaned up memory. |
Bram Moolenaar | 038e6d2 | 2022-12-08 12:00:50 +0000 | [diff] [blame] | 2985 | let lines =<< trim END |
| 2986 | set wildoptions=pum |
| 2987 | set wildchar=<C-E> |
| 2988 | END |
| 2989 | call writefile(lines, 'XwildmenuTest', 'D') |
| 2990 | let buf = RunVimInTerminal('-S XwildmenuTest', #{rows: 10}) |
| 2991 | |
Yee Cheng Chin | 8f4fb00 | 2023-10-17 10:06:56 +0200 | [diff] [blame] | 2992 | call term_sendkeys(buf, ":\<C-E>") |
| 2993 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_odd_wildchar_1', {}) |
Bram Moolenaar | 038e6d2 | 2022-12-08 12:00:50 +0000 | [diff] [blame] | 2994 | |
Yee Cheng Chin | 8f4fb00 | 2023-10-17 10:06:56 +0200 | [diff] [blame] | 2995 | " <C-E> being a wildchar takes priority over its original functionality |
| 2996 | call term_sendkeys(buf, "\<C-E>") |
| 2997 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_odd_wildchar_2', {}) |
| 2998 | |
| 2999 | call term_sendkeys(buf, "\<Esc>") |
| 3000 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_odd_wildchar_3', {}) |
| 3001 | |
| 3002 | " Escape key can be wildchar too. Double-<Esc> is hard-coded to escape |
| 3003 | " command-line, and we need to make sure to clean up properly. |
| 3004 | call term_sendkeys(buf, ":set wildchar=<Esc>\<CR>") |
| 3005 | call term_sendkeys(buf, ":\<Esc>") |
| 3006 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_odd_wildchar_1', {}) |
| 3007 | |
| 3008 | call term_sendkeys(buf, "\<Esc>") |
| 3009 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_odd_wildchar_3', {}) |
| 3010 | |
| 3011 | " <C-\> can also be wildchar. <C-\><C-N> however will still escape cmdline |
| 3012 | " and we again need to make sure we clean up properly. |
| 3013 | call term_sendkeys(buf, ":set wildchar=<C-\\>\<CR>") |
| 3014 | call term_sendkeys(buf, ":\<C-\>\<C-\>") |
| 3015 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_odd_wildchar_1', {}) |
| 3016 | |
| 3017 | call term_sendkeys(buf, "\<C-N>") |
| 3018 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_odd_wildchar_3', {}) |
| 3019 | |
| 3020 | call StopVimInTerminal(buf) |
Bram Moolenaar | 038e6d2 | 2022-12-08 12:00:50 +0000 | [diff] [blame] | 3021 | endfunc |
| 3022 | |
zeertzjq | 883018f | 2024-06-15 15:37:11 +0200 | [diff] [blame] | 3023 | " Test that 'rightleft' should not affect cmdline completion popup menu. |
| 3024 | func Test_wildmenu_pum_rightleft() |
| 3025 | CheckFeature rightleft |
| 3026 | CheckScreendump |
| 3027 | |
| 3028 | let lines =<< trim END |
| 3029 | set wildoptions=pum |
| 3030 | set rightleft |
| 3031 | END |
| 3032 | call writefile(lines, 'Xwildmenu_pum_rl', 'D') |
| 3033 | let buf = RunVimInTerminal('-S Xwildmenu_pum_rl', #{rows: 10, cols: 50}) |
| 3034 | |
| 3035 | call term_sendkeys(buf, ":sign \<Tab>") |
| 3036 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_rl', {}) |
| 3037 | |
| 3038 | call StopVimInTerminal(buf) |
| 3039 | endfunc |
| 3040 | |
Girish Palya | 4ec46f3 | 2025-03-04 20:56:30 +0100 | [diff] [blame] | 3041 | " Test highlighting when pattern matches non-first character of item |
| 3042 | func Test_wildmenu_pum_hl_nonfirst() |
| 3043 | CheckScreendump |
| 3044 | let lines =<< trim END |
| 3045 | set wildoptions=pum wildchar=<tab> wildmode=noselect,full |
| 3046 | hi PmenuMatchSel ctermfg=6 ctermbg=7 |
| 3047 | hi PmenuMatch ctermfg=4 ctermbg=225 |
| 3048 | func T(a, c, p) |
| 3049 | return ["oneA", "o neBneB", "aoneC"] |
| 3050 | endfunc |
| 3051 | command -nargs=1 -complete=customlist,T MyCmd |
| 3052 | END |
| 3053 | |
| 3054 | call writefile(lines, 'Xwildmenu_pum_hl_nonf', 'D') |
| 3055 | let buf = RunVimInTerminal('-S Xwildmenu_pum_hl_nonf', #{rows: 10, cols: 50}) |
| 3056 | |
| 3057 | call term_sendkeys(buf, ":MyCmd ne\<tab>") |
| 3058 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_hl_match_nonf', {}) |
| 3059 | call term_sendkeys(buf, "\<Esc>") |
| 3060 | call StopVimInTerminal(buf) |
| 3061 | endfunc |
| 3062 | |
zeertzjq | d8c9340 | 2024-06-17 18:25:32 +0200 | [diff] [blame] | 3063 | " Test highlighting matched text in cmdline completion popup menu. |
| 3064 | func Test_wildmenu_pum_hl_match() |
| 3065 | CheckScreendump |
| 3066 | |
| 3067 | let lines =<< trim END |
| 3068 | set wildoptions=pum,fuzzy |
| 3069 | hi PmenuMatchSel ctermfg=6 ctermbg=7 |
| 3070 | hi PmenuMatch ctermfg=4 ctermbg=225 |
| 3071 | END |
| 3072 | call writefile(lines, 'Xwildmenu_pum_hl', 'D') |
| 3073 | let buf = RunVimInTerminal('-S Xwildmenu_pum_hl', #{rows: 10, cols: 50}) |
| 3074 | |
| 3075 | call term_sendkeys(buf, ":sign plc\<Tab>") |
| 3076 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_hl_match_1', {}) |
| 3077 | call term_sendkeys(buf, "\<Tab>") |
| 3078 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_hl_match_2', {}) |
| 3079 | call term_sendkeys(buf, "\<Tab>") |
| 3080 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_hl_match_3', {}) |
| 3081 | call term_sendkeys(buf, "\<Esc>:set wildoptions-=fuzzy\<CR>") |
| 3082 | call TermWait(buf) |
| 3083 | call term_sendkeys(buf, ":sign un\<Tab>") |
| 3084 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_hl_match_4', {}) |
| 3085 | call term_sendkeys(buf, "\<Tab>") |
| 3086 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_hl_match_5', {}) |
| 3087 | call term_sendkeys(buf, "\<Tab>") |
| 3088 | call VerifyScreenDump(buf, 'Test_wildmenu_pum_hl_match_6', {}) |
| 3089 | call term_sendkeys(buf, "\<Esc>") |
| 3090 | |
| 3091 | call StopVimInTerminal(buf) |
| 3092 | endfunc |
| 3093 | |
Yegappan Lakshmanan | e3846cf | 2022-02-15 11:35:54 +0000 | [diff] [blame] | 3094 | " Test for completion after a :substitute command followed by a pipe (|) |
| 3095 | " character |
| 3096 | func Test_cmdline_complete_substitute() |
| 3097 | call feedkeys(":s | \t\<C-B>\"\<CR>", 'xt') |
| 3098 | call assert_equal("\"s | \t", @:) |
| 3099 | call feedkeys(":s/ | \t\<C-B>\"\<CR>", 'xt') |
| 3100 | call assert_equal("\"s/ | \t", @:) |
| 3101 | call feedkeys(":s/one | \t\<C-B>\"\<CR>", 'xt') |
| 3102 | call assert_equal("\"s/one | \t", @:) |
| 3103 | call feedkeys(":s/one/ | \t\<C-B>\"\<CR>", 'xt') |
| 3104 | call assert_equal("\"s/one/ | \t", @:) |
| 3105 | call feedkeys(":s/one/two | \t\<C-B>\"\<CR>", 'xt') |
| 3106 | call assert_equal("\"s/one/two | \t", @:) |
| 3107 | call feedkeys(":s/one/two/ | chist\t\<C-B>\"\<CR>", 'xt') |
| 3108 | call assert_equal('"s/one/two/ | chistory', @:) |
| 3109 | call feedkeys(":s/one/two/g \t\<C-B>\"\<CR>", 'xt') |
| 3110 | call assert_equal("\"s/one/two/g \t", @:) |
| 3111 | call feedkeys(":s/one/two/g | chist\t\<C-B>\"\<CR>", 'xt') |
| 3112 | call assert_equal("\"s/one/two/g | chistory", @:) |
| 3113 | call feedkeys(":s/one/t\\/ | \t\<C-B>\"\<CR>", 'xt') |
| 3114 | call assert_equal("\"s/one/t\\/ | \t", @:) |
| 3115 | call feedkeys(":s/one/t\"o/ | chist\t\<C-B>\"\<CR>", 'xt') |
| 3116 | call assert_equal('"s/one/t"o/ | chistory', @:) |
| 3117 | call feedkeys(":s/one/t|o/ | chist\t\<C-B>\"\<CR>", 'xt') |
| 3118 | call assert_equal('"s/one/t|o/ | chistory', @:) |
| 3119 | call feedkeys(":&\t\<C-B>\"\<CR>", 'xt') |
| 3120 | call assert_equal("\"&\t", @:) |
| 3121 | endfunc |
| 3122 | |
| 3123 | " Test for the :dlist command completion |
| 3124 | func Test_cmdline_complete_dlist() |
| 3125 | call feedkeys(":dlist 10 /pat/ a\<C-A>\<C-B>\"\<CR>", 'xt') |
| 3126 | call assert_equal("\"dlist 10 /pat/ a\<C-A>", @:) |
| 3127 | call feedkeys(":dlist 10 /pat/ \t\<C-B>\"\<CR>", 'xt') |
| 3128 | call assert_equal("\"dlist 10 /pat/ \t", @:) |
| 3129 | call feedkeys(":dlist 10 /pa\\t/\t\<C-B>\"\<CR>", 'xt') |
| 3130 | call assert_equal("\"dlist 10 /pa\\t/\t", @:) |
| 3131 | call feedkeys(":dlist 10 /pat\\\t\<C-B>\"\<CR>", 'xt') |
| 3132 | call assert_equal("\"dlist 10 /pat\\\t", @:) |
| 3133 | call feedkeys(":dlist 10 /pat/ | chist\<Tab>\<C-B>\"\<CR>", 'xt') |
| 3134 | call assert_equal("\"dlist 10 /pat/ | chistory", @:) |
| 3135 | endfunc |
| 3136 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3137 | " argument list (only for :argdel) fuzzy completion |
| 3138 | func Test_fuzzy_completion_arglist() |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3139 | argadd change.py count.py charge.py |
| 3140 | set wildoptions& |
| 3141 | call feedkeys(":argdel cge\<C-A>\<C-B>\"\<CR>", 'tx') |
| 3142 | call assert_equal('"argdel cge', @:) |
| 3143 | set wildoptions=fuzzy |
| 3144 | call feedkeys(":argdel cge\<C-A>\<C-B>\"\<CR>", 'tx') |
| 3145 | call assert_equal('"argdel change.py charge.py', @:) |
| 3146 | %argdelete |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3147 | set wildoptions& |
| 3148 | endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3149 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3150 | " autocmd group name fuzzy completion |
| 3151 | func Test_fuzzy_completion_autocmd() |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3152 | set wildoptions& |
| 3153 | augroup MyFuzzyGroup |
| 3154 | augroup END |
| 3155 | call feedkeys(":augroup mfg\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3156 | call assert_equal('"augroup mfg', @:) |
| 3157 | call feedkeys(":augroup My*p\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3158 | call assert_equal('"augroup MyFuzzyGroup', @:) |
| 3159 | set wildoptions=fuzzy |
| 3160 | call feedkeys(":augroup mfg\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3161 | call assert_equal('"augroup MyFuzzyGroup', @:) |
| 3162 | call feedkeys(":augroup My*p\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3163 | call assert_equal('"augroup My*p', @:) |
| 3164 | augroup! MyFuzzyGroup |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3165 | set wildoptions& |
| 3166 | endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3167 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3168 | " buffer name fuzzy completion |
| 3169 | func Test_fuzzy_completion_bufname() |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3170 | set wildoptions& |
Bram Moolenaar | 5ac4b1a | 2022-08-06 10:28:19 +0100 | [diff] [blame] | 3171 | " Use a long name to reduce the risk of matching a random directory name |
| 3172 | edit SomeRandomFileWithLetters.txt |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3173 | enew |
Bram Moolenaar | 5ac4b1a | 2022-08-06 10:28:19 +0100 | [diff] [blame] | 3174 | call feedkeys(":b SRFWL\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3175 | call assert_equal('"b SRFWL', @:) |
| 3176 | call feedkeys(":b S*FileWithLetters.txt\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3177 | call assert_equal('"b SomeRandomFileWithLetters.txt', @:) |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3178 | set wildoptions=fuzzy |
Bram Moolenaar | 5ac4b1a | 2022-08-06 10:28:19 +0100 | [diff] [blame] | 3179 | call feedkeys(":b SRFWL\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3180 | call assert_equal('"b SomeRandomFileWithLetters.txt', @:) |
| 3181 | call feedkeys(":b S*FileWithLetters.txt\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3182 | call assert_equal('"b S*FileWithLetters.txt', @:) |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3183 | %bw! |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3184 | set wildoptions& |
| 3185 | endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3186 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3187 | " buffer name (full path) fuzzy completion |
| 3188 | func Test_fuzzy_completion_bufname_fullpath() |
| 3189 | CheckUnix |
| 3190 | set wildoptions& |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 3191 | call mkdir('Xcmd/Xstate/Xfile.js', 'pR') |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3192 | edit Xcmd/Xstate/Xfile.js |
| 3193 | cd Xcmd/Xstate |
| 3194 | enew |
| 3195 | call feedkeys(":b CmdStateFile\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3196 | call assert_equal('"b CmdStateFile', @:) |
| 3197 | set wildoptions=fuzzy |
| 3198 | call feedkeys(":b CmdStateFile\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3199 | call assert_match('Xcmd/Xstate/Xfile.js$', @:) |
| 3200 | cd - |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3201 | set wildoptions& |
| 3202 | endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3203 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3204 | " :behave suboptions fuzzy completion |
| 3205 | func Test_fuzzy_completion_behave() |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3206 | set wildoptions& |
| 3207 | call feedkeys(":behave xm\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3208 | call assert_equal('"behave xm', @:) |
| 3209 | call feedkeys(":behave xt*m\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3210 | call assert_equal('"behave xterm', @:) |
| 3211 | set wildoptions=fuzzy |
| 3212 | call feedkeys(":behave xm\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3213 | call assert_equal('"behave xterm', @:) |
| 3214 | call feedkeys(":behave xt*m\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3215 | call assert_equal('"behave xt*m', @:) |
| 3216 | let g:Sline = '' |
| 3217 | call feedkeys(":behave win\<C-D>\<F4>\<C-B>\"\<CR>", 'tx') |
| 3218 | call assert_equal('mswin', g:Sline) |
| 3219 | call assert_equal('"behave win', @:) |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3220 | set wildoptions& |
| 3221 | endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3222 | |
Christian Brabandt | a3422aa | 2025-04-23 21:04:24 +0200 | [diff] [blame] | 3223 | " :filetype suboptions completion |
| 3224 | func Test_completion_filetypecmd() |
| 3225 | set wildoptions& |
| 3226 | call feedkeys(":filetype \<C-A>\<C-B>\"\<CR>", 'tx') |
| 3227 | call assert_equal('"filetype indent off on plugin', @:) |
| 3228 | call feedkeys(":filetype plugin \<C-A>\<C-B>\"\<CR>", 'tx') |
| 3229 | call assert_equal('"filetype plugin indent off on', @:) |
| 3230 | call feedkeys(":filetype indent \<C-A>\<C-B>\"\<CR>", 'tx') |
| 3231 | call assert_equal('"filetype indent off on plugin', @:) |
| 3232 | call feedkeys(":filetype i\<C-A>\<C-B>\"\<CR>", 'tx') |
| 3233 | call assert_equal('"filetype indent', @:) |
| 3234 | call feedkeys(":filetype p\<C-A>\<C-B>\"\<CR>", 'tx') |
| 3235 | call assert_equal('"filetype plugin', @:) |
| 3236 | call feedkeys(":filetype o\<C-A>\<C-B>\"\<CR>", 'tx') |
| 3237 | call assert_equal('"filetype off on', @:) |
| 3238 | call feedkeys(":filetype indent of\<C-A>\<C-B>\"\<CR>", 'tx') |
| 3239 | call assert_equal('"filetype indent off', @:) |
| 3240 | set wildoptions& |
| 3241 | endfunc |
| 3242 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3243 | " " colorscheme name fuzzy completion - NOT supported |
| 3244 | " func Test_fuzzy_completion_colorscheme() |
| 3245 | " endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3246 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3247 | " built-in command name fuzzy completion |
| 3248 | func Test_fuzzy_completion_cmdname() |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3249 | set wildoptions& |
| 3250 | call feedkeys(":sbwin\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3251 | call assert_equal('"sbwin', @:) |
| 3252 | call feedkeys(":sbr*d\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3253 | call assert_equal('"sbrewind', @:) |
| 3254 | set wildoptions=fuzzy |
| 3255 | call feedkeys(":sbwin\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3256 | call assert_equal('"sbrewind', @:) |
| 3257 | call feedkeys(":sbr*d\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3258 | call assert_equal('"sbr*d', @:) |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3259 | set wildoptions& |
| 3260 | endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3261 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3262 | " " compiler name fuzzy completion - NOT supported |
| 3263 | " func Test_fuzzy_completion_compiler() |
| 3264 | " endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3265 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3266 | " :cscope suboptions fuzzy completion |
| 3267 | func Test_fuzzy_completion_cscope() |
| 3268 | CheckFeature cscope |
| 3269 | set wildoptions& |
| 3270 | call feedkeys(":cscope ret\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3271 | call assert_equal('"cscope ret', @:) |
| 3272 | call feedkeys(":cscope re*t\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3273 | call assert_equal('"cscope reset', @:) |
| 3274 | set wildoptions=fuzzy |
| 3275 | call feedkeys(":cscope ret\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3276 | call assert_equal('"cscope reset', @:) |
| 3277 | call feedkeys(":cscope re*t\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3278 | call assert_equal('"cscope re*t', @:) |
| 3279 | set wildoptions& |
| 3280 | endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3281 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3282 | " :diffget/:diffput buffer name fuzzy completion |
| 3283 | func Test_fuzzy_completion_diff() |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3284 | new SomeBuffer |
| 3285 | diffthis |
| 3286 | new OtherBuffer |
| 3287 | diffthis |
| 3288 | set wildoptions& |
| 3289 | call feedkeys(":diffget sbuf\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3290 | call assert_equal('"diffget sbuf', @:) |
| 3291 | call feedkeys(":diffput sbuf\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3292 | call assert_equal('"diffput sbuf', @:) |
| 3293 | set wildoptions=fuzzy |
| 3294 | call feedkeys(":diffget sbuf\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3295 | call assert_equal('"diffget SomeBuffer', @:) |
| 3296 | call feedkeys(":diffput sbuf\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3297 | call assert_equal('"diffput SomeBuffer', @:) |
| 3298 | %bw! |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3299 | set wildoptions& |
| 3300 | endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3301 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3302 | " " directory name fuzzy completion - NOT supported |
| 3303 | " func Test_fuzzy_completion_dirname() |
| 3304 | " endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3305 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3306 | " environment variable name fuzzy completion |
| 3307 | func Test_fuzzy_completion_env() |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3308 | set wildoptions& |
| 3309 | call feedkeys(":echo $VUT\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3310 | call assert_equal('"echo $VUT', @:) |
| 3311 | set wildoptions=fuzzy |
| 3312 | call feedkeys(":echo $VUT\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3313 | call assert_equal('"echo $VIMRUNTIME', @:) |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3314 | set wildoptions& |
| 3315 | endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3316 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3317 | " autocmd event fuzzy completion |
| 3318 | func Test_fuzzy_completion_autocmd_event() |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3319 | set wildoptions& |
| 3320 | call feedkeys(":autocmd BWout\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3321 | call assert_equal('"autocmd BWout', @:) |
| 3322 | set wildoptions=fuzzy |
| 3323 | call feedkeys(":autocmd BWout\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3324 | call assert_equal('"autocmd BufWipeout', @:) |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3325 | set wildoptions& |
| 3326 | endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3327 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3328 | " vim expression fuzzy completion |
| 3329 | func Test_fuzzy_completion_expr() |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3330 | let g:PerPlaceCount = 10 |
| 3331 | set wildoptions& |
| 3332 | call feedkeys(":let c = ppc\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3333 | call assert_equal('"let c = ppc', @:) |
| 3334 | set wildoptions=fuzzy |
| 3335 | call feedkeys(":let c = ppc\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3336 | call assert_equal('"let c = PerPlaceCount', @:) |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3337 | set wildoptions& |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3338 | endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3339 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3340 | " " file name fuzzy completion - NOT supported |
| 3341 | " func Test_fuzzy_completion_filename() |
| 3342 | " endfunc |
| 3343 | |
| 3344 | " " files in path fuzzy completion - NOT supported |
| 3345 | " func Test_fuzzy_completion_filesinpath() |
| 3346 | " endfunc |
| 3347 | |
| 3348 | " " filetype name fuzzy completion - NOT supported |
| 3349 | " func Test_fuzzy_completion_filetype() |
| 3350 | " endfunc |
| 3351 | |
| 3352 | " user defined function name completion |
| 3353 | func Test_fuzzy_completion_userdefined_func() |
| 3354 | set wildoptions& |
| 3355 | call feedkeys(":call Test_f_u_f\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3356 | call assert_equal('"call Test_f_u_f', @:) |
| 3357 | set wildoptions=fuzzy |
| 3358 | call feedkeys(":call Test_f_u_f\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3359 | call assert_equal('"call Test_fuzzy_completion_userdefined_func()', @:) |
| 3360 | set wildoptions& |
| 3361 | endfunc |
| 3362 | |
Yegappan Lakshmanan | 5de4c43 | 2022-02-28 13:28:38 +0000 | [diff] [blame] | 3363 | " <SNR> functions should be sorted to the end |
| 3364 | func Test_fuzzy_completion_userdefined_snr_func() |
| 3365 | func s:Sendmail() |
| 3366 | endfunc |
| 3367 | func SendSomemail() |
| 3368 | endfunc |
| 3369 | func S1e2n3dmail() |
| 3370 | endfunc |
| 3371 | set wildoptions=fuzzy |
| 3372 | call feedkeys(":call sendmail\<C-A>\<C-B>\"\<CR>", 'tx') |
Bram Moolenaar | fe8e9f6 | 2022-03-16 13:09:15 +0000 | [diff] [blame] | 3373 | call assert_match('"call SendSomemail() S1e2n3dmail() <SNR>\d\+_Sendmail()', @:) |
Yegappan Lakshmanan | 5de4c43 | 2022-02-28 13:28:38 +0000 | [diff] [blame] | 3374 | set wildoptions& |
| 3375 | delfunc s:Sendmail |
| 3376 | delfunc SendSomemail |
| 3377 | delfunc S1e2n3dmail |
| 3378 | endfunc |
| 3379 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3380 | " user defined command name completion |
| 3381 | func Test_fuzzy_completion_userdefined_cmd() |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3382 | set wildoptions& |
| 3383 | call feedkeys(":MsFeat\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3384 | call assert_equal('"MsFeat', @:) |
| 3385 | set wildoptions=fuzzy |
| 3386 | call feedkeys(":MsFeat\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3387 | call assert_equal('"MissingFeature', @:) |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3388 | set wildoptions& |
| 3389 | endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3390 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3391 | " " :help tag fuzzy completion - NOT supported |
| 3392 | " func Test_fuzzy_completion_helptag() |
| 3393 | " endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3394 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3395 | " highlight group name fuzzy completion |
| 3396 | func Test_fuzzy_completion_hlgroup() |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3397 | set wildoptions& |
| 3398 | call feedkeys(":highlight SKey\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3399 | call assert_equal('"highlight SKey', @:) |
| 3400 | call feedkeys(":highlight Sp*Key\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3401 | call assert_equal('"highlight SpecialKey', @:) |
| 3402 | set wildoptions=fuzzy |
| 3403 | call feedkeys(":highlight SKey\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3404 | call assert_equal('"highlight SpecialKey', @:) |
| 3405 | call feedkeys(":highlight Sp*Key\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3406 | call assert_equal('"highlight Sp*Key', @:) |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3407 | set wildoptions& |
| 3408 | endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3409 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3410 | " :history suboptions fuzzy completion |
| 3411 | func Test_fuzzy_completion_history() |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3412 | set wildoptions& |
| 3413 | call feedkeys(":history dg\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3414 | call assert_equal('"history dg', @:) |
| 3415 | call feedkeys(":history se*h\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3416 | call assert_equal('"history search', @:) |
| 3417 | set wildoptions=fuzzy |
| 3418 | call feedkeys(":history dg\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3419 | call assert_equal('"history debug', @:) |
| 3420 | call feedkeys(":history se*h\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3421 | call assert_equal('"history se*h', @:) |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3422 | set wildoptions& |
| 3423 | endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3424 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3425 | " :language locale name fuzzy completion |
| 3426 | func Test_fuzzy_completion_lang() |
| 3427 | CheckUnix |
| 3428 | set wildoptions& |
| 3429 | call feedkeys(":lang psx\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3430 | call assert_equal('"lang psx', @:) |
| 3431 | set wildoptions=fuzzy |
| 3432 | call feedkeys(":lang psx\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3433 | call assert_equal('"lang POSIX', @:) |
| 3434 | set wildoptions& |
| 3435 | endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3436 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3437 | " :mapclear buffer argument fuzzy completion |
| 3438 | func Test_fuzzy_completion_mapclear() |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3439 | set wildoptions& |
| 3440 | call feedkeys(":mapclear buf\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3441 | call assert_equal('"mapclear buf', @:) |
| 3442 | set wildoptions=fuzzy |
| 3443 | call feedkeys(":mapclear buf\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3444 | call assert_equal('"mapclear <buffer>', @:) |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3445 | set wildoptions& |
| 3446 | endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3447 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3448 | " map name fuzzy completion |
| 3449 | func Test_fuzzy_completion_mapname() |
Yegappan Lakshmanan | 00333cb | 2022-02-26 16:05:08 +0000 | [diff] [blame] | 3450 | " test regex completion works |
| 3451 | set wildoptions=fuzzy |
| 3452 | call feedkeys(":cnoremap <ex\<Tab> <esc> \<Tab>\<C-B>\"\<CR>", 'tx') |
| 3453 | call assert_equal("\"cnoremap <expr> <esc> \<Tab>", @:) |
Yegappan Lakshmanan | 6caeda2 | 2022-02-27 12:07:30 +0000 | [diff] [blame] | 3454 | nmap <plug>MyLongMap :p<CR> |
| 3455 | call feedkeys(":nmap MLM\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3456 | call assert_equal("\"nmap <Plug>MyLongMap", @:) |
| 3457 | call feedkeys(":nmap MLM \<Tab>\<C-B>\"\<CR>", 'tx') |
| 3458 | call assert_equal("\"nmap MLM \t", @:) |
| 3459 | call feedkeys(":nmap <F2> one two \<Tab>\<C-B>\"\<CR>", 'tx') |
| 3460 | call assert_equal("\"nmap <F2> one two \t", @:) |
| 3461 | " duplicate entries should be removed |
| 3462 | vmap <plug>MyLongMap :<C-U>#<CR> |
| 3463 | call feedkeys(":nmap MLM\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3464 | call assert_equal("\"nmap <Plug>MyLongMap", @:) |
| 3465 | nunmap <plug>MyLongMap |
| 3466 | vunmap <plug>MyLongMap |
| 3467 | call feedkeys(":nmap ABC\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3468 | call assert_equal("\"nmap ABC\t", @:) |
| 3469 | " results should be sorted by best match |
| 3470 | nmap <Plug>format : |
| 3471 | nmap <Plug>goformat : |
| 3472 | nmap <Plug>TestFOrmat : |
| 3473 | nmap <Plug>fendoff : |
| 3474 | nmap <Plug>state : |
| 3475 | nmap <Plug>FendingOff : |
| 3476 | call feedkeys(":nmap <Plug>fo\<C-A>\<C-B>\"\<CR>", 'tx') |
| 3477 | call assert_equal("\"nmap <Plug>format <Plug>TestFOrmat <Plug>FendingOff <Plug>goformat <Plug>fendoff", @:) |
| 3478 | nunmap <Plug>format |
| 3479 | nunmap <Plug>goformat |
| 3480 | nunmap <Plug>TestFOrmat |
| 3481 | nunmap <Plug>fendoff |
| 3482 | nunmap <Plug>state |
| 3483 | nunmap <Plug>FendingOff |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3484 | set wildoptions& |
| 3485 | endfunc |
Yegappan Lakshmanan | 6caeda2 | 2022-02-27 12:07:30 +0000 | [diff] [blame] | 3486 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3487 | " abbreviation fuzzy completion |
| 3488 | func Test_fuzzy_completion_abbr() |
Yegappan Lakshmanan | 6caeda2 | 2022-02-27 12:07:30 +0000 | [diff] [blame] | 3489 | set wildoptions=fuzzy |
| 3490 | call feedkeys(":iabbr wait\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3491 | call assert_equal("\"iabbr <nowait>", @:) |
| 3492 | iabbr WaitForCompletion WFC |
| 3493 | call feedkeys(":iabbr fcl\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3494 | call assert_equal("\"iabbr WaitForCompletion", @:) |
| 3495 | call feedkeys(":iabbr a1z\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3496 | call assert_equal("\"iabbr a1z\t", @:) |
zeertzjq | 145a6af | 2023-01-22 12:41:55 +0000 | [diff] [blame] | 3497 | |
Yegappan Lakshmanan | 6caeda2 | 2022-02-27 12:07:30 +0000 | [diff] [blame] | 3498 | iunabbrev WaitForCompletion |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3499 | set wildoptions& |
| 3500 | endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3501 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3502 | " menu name fuzzy completion |
| 3503 | func Test_fuzzy_completion_menu() |
zeertzjq | 145a6af | 2023-01-22 12:41:55 +0000 | [diff] [blame] | 3504 | CheckFeature menu |
| 3505 | |
| 3506 | source $VIMRUNTIME/menu.vim |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3507 | set wildoptions& |
| 3508 | call feedkeys(":menu pup\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3509 | call assert_equal('"menu pup', @:) |
| 3510 | set wildoptions=fuzzy |
| 3511 | call feedkeys(":menu pup\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3512 | call assert_equal('"menu PopUp.', @:) |
zeertzjq | 145a6af | 2023-01-22 12:41:55 +0000 | [diff] [blame] | 3513 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3514 | set wildoptions& |
zeertzjq | 145a6af | 2023-01-22 12:41:55 +0000 | [diff] [blame] | 3515 | source $VIMRUNTIME/delmenu.vim |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3516 | endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3517 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3518 | " :messages suboptions fuzzy completion |
| 3519 | func Test_fuzzy_completion_messages() |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3520 | set wildoptions& |
| 3521 | call feedkeys(":messages clr\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3522 | call assert_equal('"messages clr', @:) |
| 3523 | set wildoptions=fuzzy |
| 3524 | call feedkeys(":messages clr\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3525 | call assert_equal('"messages clear', @:) |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3526 | set wildoptions& |
| 3527 | endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3528 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3529 | " :set option name fuzzy completion |
| 3530 | func Test_fuzzy_completion_option() |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3531 | set wildoptions& |
| 3532 | call feedkeys(":set brkopt\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3533 | call assert_equal('"set brkopt', @:) |
| 3534 | set wildoptions=fuzzy |
| 3535 | call feedkeys(":set brkopt\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3536 | call assert_equal('"set breakindentopt', @:) |
| 3537 | set wildoptions& |
| 3538 | call feedkeys(":set fixeol\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3539 | call assert_equal('"set fixendofline', @:) |
| 3540 | set wildoptions=fuzzy |
| 3541 | call feedkeys(":set fixeol\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3542 | call assert_equal('"set fixendofline', @:) |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3543 | set wildoptions& |
| 3544 | endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3545 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3546 | " :set <term_option> |
| 3547 | func Test_fuzzy_completion_term_option() |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3548 | set wildoptions& |
| 3549 | call feedkeys(":set t_E\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3550 | call assert_equal('"set t_EC', @:) |
| 3551 | call feedkeys(":set <t_E\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3552 | call assert_equal('"set <t_EC>', @:) |
| 3553 | set wildoptions=fuzzy |
| 3554 | call feedkeys(":set t_E\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3555 | call assert_equal('"set t_EC', @:) |
| 3556 | call feedkeys(":set <t_E\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3557 | call assert_equal('"set <t_EC>', @:) |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3558 | set wildoptions& |
| 3559 | endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3560 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3561 | " " :packadd directory name fuzzy completion - NOT supported |
| 3562 | " func Test_fuzzy_completion_packadd() |
| 3563 | " endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3564 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3565 | " " shell command name fuzzy completion - NOT supported |
| 3566 | " func Test_fuzzy_completion_shellcmd() |
| 3567 | " endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3568 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3569 | " :sign suboptions fuzzy completion |
| 3570 | func Test_fuzzy_completion_sign() |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3571 | set wildoptions& |
| 3572 | call feedkeys(":sign ufe\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3573 | call assert_equal('"sign ufe', @:) |
| 3574 | set wildoptions=fuzzy |
| 3575 | call feedkeys(":sign ufe\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3576 | call assert_equal('"sign undefine', @:) |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3577 | set wildoptions& |
| 3578 | endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3579 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3580 | " :syntax suboptions fuzzy completion |
| 3581 | func Test_fuzzy_completion_syntax_cmd() |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3582 | set wildoptions& |
| 3583 | call feedkeys(":syntax kwd\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3584 | call assert_equal('"syntax kwd', @:) |
| 3585 | set wildoptions=fuzzy |
| 3586 | call feedkeys(":syntax kwd\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3587 | call assert_equal('"syntax keyword', @:) |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3588 | set wildoptions& |
| 3589 | endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3590 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3591 | " syntax group name fuzzy completion |
| 3592 | func Test_fuzzy_completion_syntax_group() |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3593 | set wildoptions& |
| 3594 | call feedkeys(":syntax list mpar\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3595 | call assert_equal('"syntax list mpar', @:) |
| 3596 | set wildoptions=fuzzy |
| 3597 | call feedkeys(":syntax list mpar\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3598 | call assert_equal('"syntax list MatchParen', @:) |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3599 | set wildoptions& |
| 3600 | endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3601 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3602 | " :syntime suboptions fuzzy completion |
| 3603 | func Test_fuzzy_completion_syntime() |
| 3604 | CheckFeature profile |
| 3605 | set wildoptions& |
| 3606 | call feedkeys(":syntime clr\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3607 | call assert_equal('"syntime clr', @:) |
| 3608 | set wildoptions=fuzzy |
| 3609 | call feedkeys(":syntime clr\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3610 | call assert_equal('"syntime clear', @:) |
| 3611 | set wildoptions& |
| 3612 | endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3613 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3614 | " " tag name fuzzy completion - NOT supported |
| 3615 | " func Test_fuzzy_completion_tagname() |
| 3616 | " endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3617 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3618 | " " tag name and file fuzzy completion - NOT supported |
| 3619 | " func Test_fuzzy_completion_tagfile() |
| 3620 | " endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3621 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3622 | " " user names fuzzy completion - how to test this functionality? |
| 3623 | " func Test_fuzzy_completion_username() |
| 3624 | " endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3625 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3626 | " user defined variable name fuzzy completion |
| 3627 | func Test_fuzzy_completion_userdefined_var() |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3628 | let g:SomeVariable=10 |
| 3629 | set wildoptions& |
| 3630 | call feedkeys(":let SVar\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3631 | call assert_equal('"let SVar', @:) |
| 3632 | set wildoptions=fuzzy |
| 3633 | call feedkeys(":let SVar\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3634 | call assert_equal('"let SomeVariable', @:) |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3635 | set wildoptions& |
| 3636 | endfunc |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3637 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3638 | " Test for sorting the results by the best match |
| 3639 | func Test_fuzzy_completion_cmd_sort_results() |
Yegappan Lakshmanan | 5ec633b | 2022-02-25 15:24:24 +0000 | [diff] [blame] | 3640 | %bw! |
| 3641 | command T123format : |
| 3642 | command T123goformat : |
| 3643 | command T123TestFOrmat : |
| 3644 | command T123fendoff : |
| 3645 | command T123state : |
| 3646 | command T123FendingOff : |
| 3647 | set wildoptions=fuzzy |
| 3648 | call feedkeys(":T123fo\<C-A>\<C-B>\"\<CR>", 'tx') |
| 3649 | call assert_equal('"T123format T123TestFOrmat T123FendingOff T123goformat T123fendoff', @:) |
| 3650 | delcommand T123format |
| 3651 | delcommand T123goformat |
| 3652 | delcommand T123TestFOrmat |
| 3653 | delcommand T123fendoff |
| 3654 | delcommand T123state |
| 3655 | delcommand T123FendingOff |
| 3656 | %bw |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3657 | set wildoptions& |
| 3658 | endfunc |
Yegappan Lakshmanan | 5ec633b | 2022-02-25 15:24:24 +0000 | [diff] [blame] | 3659 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3660 | " Test for fuzzy completion of a command with lower case letters and a number |
| 3661 | func Test_fuzzy_completion_cmd_alnum() |
Yegappan Lakshmanan | 4df5b33 | 2022-02-26 11:04:42 +0000 | [diff] [blame] | 3662 | command Foo2Bar : |
| 3663 | set wildoptions=fuzzy |
| 3664 | call feedkeys(":foo2\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3665 | call assert_equal('"Foo2Bar', @:) |
| 3666 | call feedkeys(":foo\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3667 | call assert_equal('"Foo2Bar', @:) |
| 3668 | call feedkeys(":bar\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3669 | call assert_equal('"Foo2Bar', @:) |
| 3670 | delcommand Foo2Bar |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3671 | set wildoptions& |
| 3672 | endfunc |
Yegappan Lakshmanan | 4df5b33 | 2022-02-26 11:04:42 +0000 | [diff] [blame] | 3673 | |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3674 | " Test for command completion for a command starting with 'k' |
| 3675 | func Test_fuzzy_completion_cmd_k() |
Yegappan Lakshmanan | 6caeda2 | 2022-02-27 12:07:30 +0000 | [diff] [blame] | 3676 | command KillKillKill : |
| 3677 | set wildoptions& |
| 3678 | call feedkeys(":killkill\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3679 | call assert_equal("\"killkill\<Tab>", @:) |
| 3680 | set wildoptions=fuzzy |
| 3681 | call feedkeys(":killkill\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3682 | call assert_equal('"KillKillKill', @:) |
| 3683 | delcom KillKillKill |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3684 | set wildoptions& |
Yegappan Lakshmanan | afd4ae3 | 2022-02-27 21:03:21 +0000 | [diff] [blame] | 3685 | endfunc |
| 3686 | |
| 3687 | " Test for fuzzy completion for user defined custom completion function |
| 3688 | func Test_fuzzy_completion_custom_func() |
| 3689 | func Tcompl(a, c, p) |
| 3690 | return "format\ngoformat\nTestFOrmat\nfendoff\nstate" |
| 3691 | endfunc |
| 3692 | command -nargs=* -complete=custom,Tcompl Fuzzy : |
| 3693 | set wildoptions& |
| 3694 | call feedkeys(":Fuzzy fo\<C-A>\<C-B>\"\<CR>", 'tx') |
| 3695 | call assert_equal("\"Fuzzy format", @:) |
| 3696 | call feedkeys(":Fuzzy xy\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3697 | call assert_equal("\"Fuzzy xy", @:) |
| 3698 | call feedkeys(":Fuzzy ttt\<C-A>\<C-B>\"\<CR>", 'tx') |
| 3699 | call assert_equal("\"Fuzzy ttt", @:) |
| 3700 | set wildoptions=fuzzy |
| 3701 | call feedkeys(":Fuzzy \<C-A>\<C-B>\"\<CR>", 'tx') |
| 3702 | call assert_equal("\"Fuzzy format goformat TestFOrmat fendoff state", @:) |
| 3703 | call feedkeys(":Fuzzy fo\<C-A>\<C-B>\"\<CR>", 'tx') |
| 3704 | call assert_equal("\"Fuzzy format TestFOrmat goformat fendoff", @:) |
| 3705 | call feedkeys(":Fuzzy xy\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3706 | call assert_equal("\"Fuzzy xy", @:) |
| 3707 | call feedkeys(":Fuzzy ttt\<C-A>\<C-B>\"\<CR>", 'tx') |
| 3708 | call assert_equal("\"Fuzzy TestFOrmat", @:) |
| 3709 | delcom Fuzzy |
| 3710 | set wildoptions& |
Yegappan Lakshmanan | 38b85cb | 2022-02-24 13:28:41 +0000 | [diff] [blame] | 3711 | endfunc |
| 3712 | |
Yee Cheng Chin | 209ec90 | 2023-10-17 10:56:25 +0200 | [diff] [blame] | 3713 | " Test for fuzzy completion in the middle of a cmdline instead of at the end |
| 3714 | func Test_fuzzy_completion_in_middle() |
| 3715 | set wildoptions=fuzzy |
| 3716 | call feedkeys(":set ildar wrap\<Left>\<Left>\<Left>\<Left>\<Left>\<C-A>\<C-B>\"\<CR>", 'tx') |
| 3717 | call assert_equal("\"set wildchar wildcharm wrap", @:) |
| 3718 | |
| 3719 | call feedkeys(":args ++odng zz\<Left>\<Left>\<Left>\<C-A>\<C-B>\"\<CR>", 'tx') |
| 3720 | call assert_equal("\"args ++encoding= zz", @:) |
| 3721 | set wildoptions& |
| 3722 | endfunc |
| 3723 | |
Bram Moolenaar | 6e2e2cc | 2022-03-14 19:24:46 +0000 | [diff] [blame] | 3724 | " Test for :breakadd argument completion |
| 3725 | func Test_cmdline_complete_breakadd() |
| 3726 | call feedkeys(":breakadd \<C-A>\<C-B>\"\<CR>", 'tx') |
| 3727 | call assert_equal("\"breakadd expr file func here", @:) |
| 3728 | call feedkeys(":breakadd \<Tab>\<C-B>\"\<CR>", 'tx') |
| 3729 | call assert_equal("\"breakadd expr", @:) |
| 3730 | call feedkeys(":breakadd \<Tab>\<C-B>\"\<CR>", 'tx') |
| 3731 | call assert_equal("\"breakadd expr", @:) |
| 3732 | call feedkeys(":breakadd he\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3733 | call assert_equal("\"breakadd here", @:) |
| 3734 | call feedkeys(":breakadd he\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3735 | call assert_equal("\"breakadd here", @:) |
| 3736 | call feedkeys(":breakadd abc\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3737 | call assert_equal("\"breakadd abc", @:) |
| 3738 | call assert_equal(['expr', 'file', 'func', 'here'], getcompletion('', 'breakpoint')) |
| 3739 | let l = getcompletion('not', 'breakpoint') |
| 3740 | call assert_equal([], l) |
| 3741 | |
| 3742 | " Test for :breakadd file [lnum] <file> |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 3743 | call writefile([], 'Xscript', 'D') |
Bram Moolenaar | 6e2e2cc | 2022-03-14 19:24:46 +0000 | [diff] [blame] | 3744 | call feedkeys(":breakadd file Xsc\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3745 | call assert_equal("\"breakadd file Xscript", @:) |
| 3746 | call feedkeys(":breakadd file Xsc\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3747 | call assert_equal("\"breakadd file Xscript", @:) |
| 3748 | call feedkeys(":breakadd file 20 Xsc\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3749 | call assert_equal("\"breakadd file 20 Xscript", @:) |
| 3750 | call feedkeys(":breakadd file 20 Xsc\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3751 | call assert_equal("\"breakadd file 20 Xscript", @:) |
| 3752 | call feedkeys(":breakadd file 20x Xsc\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3753 | call assert_equal("\"breakadd file 20x Xsc\t", @:) |
| 3754 | call feedkeys(":breakadd file 20\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3755 | call assert_equal("\"breakadd file 20\t", @:) |
| 3756 | call feedkeys(":breakadd file 20x\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3757 | call assert_equal("\"breakadd file 20x\t", @:) |
| 3758 | call feedkeys(":breakadd file Xscript \<Tab>\<C-B>\"\<CR>", 'tx') |
| 3759 | call assert_equal("\"breakadd file Xscript ", @:) |
| 3760 | call feedkeys(":breakadd file X1B2C3\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3761 | call assert_equal("\"breakadd file X1B2C3", @:) |
Bram Moolenaar | 6e2e2cc | 2022-03-14 19:24:46 +0000 | [diff] [blame] | 3762 | |
| 3763 | " Test for :breakadd func [lnum] <function> |
| 3764 | func Xbreak_func() |
| 3765 | endfunc |
| 3766 | call feedkeys(":breakadd func Xbr\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3767 | call assert_equal("\"breakadd func Xbreak_func", @:) |
| 3768 | call feedkeys(":breakadd func Xbr\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3769 | call assert_equal("\"breakadd func Xbreak_func", @:) |
| 3770 | call feedkeys(":breakadd func 20 Xbr\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3771 | call assert_equal("\"breakadd func 20 Xbreak_func", @:) |
| 3772 | call feedkeys(":breakadd func 20 Xbr\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3773 | call assert_equal("\"breakadd func 20 Xbreak_func", @:) |
| 3774 | call feedkeys(":breakadd func 20x Xbr\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3775 | call assert_equal("\"breakadd func 20x Xbr\t", @:) |
| 3776 | call feedkeys(":breakadd func 20\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3777 | call assert_equal("\"breakadd func 20\t", @:) |
| 3778 | call feedkeys(":breakadd func 20x\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3779 | call assert_equal("\"breakadd func 20x\t", @:) |
| 3780 | call feedkeys(":breakadd func Xbreak_func \<Tab>\<C-B>\"\<CR>", 'tx') |
| 3781 | call assert_equal("\"breakadd func Xbreak_func ", @:) |
| 3782 | call feedkeys(":breakadd func X1B2C3\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3783 | call assert_equal("\"breakadd func X1B2C3", @:) |
| 3784 | delfunc Xbreak_func |
| 3785 | |
| 3786 | " Test for :breakadd expr <expression> |
| 3787 | let g:Xtest_var = 10 |
| 3788 | call feedkeys(":breakadd expr Xtest\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3789 | call assert_equal("\"breakadd expr Xtest_var", @:) |
| 3790 | call feedkeys(":breakadd expr Xtest\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3791 | call assert_equal("\"breakadd expr Xtest_var", @:) |
| 3792 | call feedkeys(":breakadd expr Xtest_var \<Tab>\<C-B>\"\<CR>", 'tx') |
| 3793 | call assert_equal("\"breakadd expr Xtest_var ", @:) |
| 3794 | call feedkeys(":breakadd expr X1B2C3\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3795 | call assert_equal("\"breakadd expr X1B2C3", @:) |
| 3796 | unlet g:Xtest_var |
| 3797 | |
| 3798 | " Test for :breakadd here |
| 3799 | call feedkeys(":breakadd here Xtest\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3800 | call assert_equal("\"breakadd here Xtest", @:) |
| 3801 | call feedkeys(":breakadd here Xtest\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3802 | call assert_equal("\"breakadd here Xtest", @:) |
| 3803 | call feedkeys(":breakadd here \<Tab>\<C-B>\"\<CR>", 'tx') |
| 3804 | call assert_equal("\"breakadd here ", @:) |
| 3805 | endfunc |
| 3806 | |
| 3807 | " Test for :breakdel argument completion |
| 3808 | func Test_cmdline_complete_breakdel() |
| 3809 | call feedkeys(":breakdel \<C-A>\<C-B>\"\<CR>", 'tx') |
| 3810 | call assert_equal("\"breakdel file func here", @:) |
| 3811 | call feedkeys(":breakdel \<Tab>\<C-B>\"\<CR>", 'tx') |
| 3812 | call assert_equal("\"breakdel file", @:) |
| 3813 | call feedkeys(":breakdel \<Tab>\<C-B>\"\<CR>", 'tx') |
| 3814 | call assert_equal("\"breakdel file", @:) |
| 3815 | call feedkeys(":breakdel he\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3816 | call assert_equal("\"breakdel here", @:) |
| 3817 | call feedkeys(":breakdel he\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3818 | call assert_equal("\"breakdel here", @:) |
| 3819 | call feedkeys(":breakdel abc\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3820 | call assert_equal("\"breakdel abc", @:) |
| 3821 | |
| 3822 | " Test for :breakdel file [lnum] <file> |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 3823 | call writefile([], 'Xscript', 'D') |
Bram Moolenaar | 6e2e2cc | 2022-03-14 19:24:46 +0000 | [diff] [blame] | 3824 | call feedkeys(":breakdel file Xsc\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3825 | call assert_equal("\"breakdel file Xscript", @:) |
| 3826 | call feedkeys(":breakdel file Xsc\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3827 | call assert_equal("\"breakdel file Xscript", @:) |
| 3828 | call feedkeys(":breakdel file 20 Xsc\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3829 | call assert_equal("\"breakdel file 20 Xscript", @:) |
| 3830 | call feedkeys(":breakdel file 20 Xsc\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3831 | call assert_equal("\"breakdel file 20 Xscript", @:) |
| 3832 | call feedkeys(":breakdel file 20x Xsc\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3833 | call assert_equal("\"breakdel file 20x Xsc\t", @:) |
| 3834 | call feedkeys(":breakdel file 20\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3835 | call assert_equal("\"breakdel file 20\t", @:) |
| 3836 | call feedkeys(":breakdel file 20x\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3837 | call assert_equal("\"breakdel file 20x\t", @:) |
| 3838 | call feedkeys(":breakdel file Xscript \<Tab>\<C-B>\"\<CR>", 'tx') |
| 3839 | call assert_equal("\"breakdel file Xscript ", @:) |
| 3840 | call feedkeys(":breakdel file X1B2C3\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3841 | call assert_equal("\"breakdel file X1B2C3", @:) |
Bram Moolenaar | 6e2e2cc | 2022-03-14 19:24:46 +0000 | [diff] [blame] | 3842 | |
| 3843 | " Test for :breakdel func [lnum] <function> |
| 3844 | func Xbreak_func() |
| 3845 | endfunc |
| 3846 | call feedkeys(":breakdel func Xbr\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3847 | call assert_equal("\"breakdel func Xbreak_func", @:) |
| 3848 | call feedkeys(":breakdel func Xbr\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3849 | call assert_equal("\"breakdel func Xbreak_func", @:) |
| 3850 | call feedkeys(":breakdel func 20 Xbr\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3851 | call assert_equal("\"breakdel func 20 Xbreak_func", @:) |
| 3852 | call feedkeys(":breakdel func 20 Xbr\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3853 | call assert_equal("\"breakdel func 20 Xbreak_func", @:) |
| 3854 | call feedkeys(":breakdel func 20x Xbr\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3855 | call assert_equal("\"breakdel func 20x Xbr\t", @:) |
| 3856 | call feedkeys(":breakdel func 20\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3857 | call assert_equal("\"breakdel func 20\t", @:) |
| 3858 | call feedkeys(":breakdel func 20x\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3859 | call assert_equal("\"breakdel func 20x\t", @:) |
| 3860 | call feedkeys(":breakdel func Xbreak_func \<Tab>\<C-B>\"\<CR>", 'tx') |
| 3861 | call assert_equal("\"breakdel func Xbreak_func ", @:) |
| 3862 | call feedkeys(":breakdel func X1B2C3\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3863 | call assert_equal("\"breakdel func X1B2C3", @:) |
| 3864 | delfunc Xbreak_func |
| 3865 | |
| 3866 | " Test for :breakdel here |
| 3867 | call feedkeys(":breakdel here Xtest\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3868 | call assert_equal("\"breakdel here Xtest", @:) |
| 3869 | call feedkeys(":breakdel here Xtest\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3870 | call assert_equal("\"breakdel here Xtest", @:) |
| 3871 | call feedkeys(":breakdel here \<Tab>\<C-B>\"\<CR>", 'tx') |
| 3872 | call assert_equal("\"breakdel here ", @:) |
Bram Moolenaar | 6e2e2cc | 2022-03-14 19:24:46 +0000 | [diff] [blame] | 3873 | endfunc |
| 3874 | |
Yegappan Lakshmanan | 454ce67 | 2022-03-24 11:22:13 +0000 | [diff] [blame] | 3875 | " Test for :scriptnames argument completion |
| 3876 | func Test_cmdline_complete_scriptnames() |
| 3877 | set wildmenu |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 3878 | call writefile(['let a = 1'], 'Xa1b2c3.vim', 'D') |
Yegappan Lakshmanan | 454ce67 | 2022-03-24 11:22:13 +0000 | [diff] [blame] | 3879 | source Xa1b2c3.vim |
| 3880 | call feedkeys(":script \<Tab>\<Left>\<Left>\<C-B>\"\<CR>", 'tx') |
| 3881 | call assert_match("\"script .*Xa1b2c3.vim$", @:) |
| 3882 | call feedkeys(":script \<Tab>\<Left>\<Left>\<C-B>\"\<CR>", 'tx') |
| 3883 | call assert_match("\"script .*Xa1b2c3.vim$", @:) |
| 3884 | call feedkeys(":script b2c3\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3885 | call assert_equal("\"script b2c3", @:) |
| 3886 | call feedkeys(":script 2\<Tab>\<C-B>\"\<CR>", 'tx') |
| 3887 | call assert_match("\"script 2\<Tab>$", @:) |
| 3888 | call feedkeys(":script \<Tab>\<Left>\<Left> \<Tab>\<C-B>\"\<CR>", 'tx') |
| 3889 | call assert_match("\"script .*Xa1b2c3.vim $", @:) |
| 3890 | call feedkeys(":script \<Tab>\<Left>\<C-B>\"\<CR>", 'tx') |
| 3891 | call assert_equal("\"script ", @:) |
| 3892 | call assert_match('Xa1b2c3.vim$', getcompletion('.*Xa1b2.*', 'scriptnames')[0]) |
| 3893 | call assert_equal([], getcompletion('Xa1b2', 'scriptnames')) |
| 3894 | new |
| 3895 | call feedkeys(":script \<Tab>\<Left>\<Left>\<CR>", 'tx') |
| 3896 | call assert_equal('Xa1b2c3.vim', fnamemodify(@%, ':t')) |
| 3897 | bw! |
Yegappan Lakshmanan | 454ce67 | 2022-03-24 11:22:13 +0000 | [diff] [blame] | 3898 | set wildmenu& |
| 3899 | endfunc |
| 3900 | |
Bram Moolenaar | d889344 | 2022-05-06 20:38:47 +0100 | [diff] [blame] | 3901 | " this was going over the end of IObuff |
| 3902 | func Test_report_error_with_composing() |
| 3903 | let caught = 'no' |
| 3904 | try |
| 3905 | exe repeat('0', 987) .. "0\xdd\x80\xdd\x80\xdd\x80\xdd\x80" |
| 3906 | catch /E492:/ |
| 3907 | let caught = 'yes' |
| 3908 | endtry |
| 3909 | call assert_equal('yes', caught) |
| 3910 | endfunc |
| 3911 | |
Yegappan Lakshmanan | 5e877ba | 2022-03-25 21:19:26 +0000 | [diff] [blame] | 3912 | " Test for expanding 2-letter and 3-letter :substitute command arguments. |
| 3913 | " These commands don't accept an argument. |
| 3914 | func Test_cmdline_complete_substitute_short() |
| 3915 | for cmd in ['sc', 'sce', 'scg', 'sci', 'scI', 'scn', 'scp', 'scl', |
| 3916 | \ 'sgc', 'sge', 'sg', 'sgi', 'sgI', 'sgn', 'sgp', 'sgl', 'sgr', |
| 3917 | \ 'sic', 'sie', 'si', 'siI', 'sin', 'sip', 'sir', |
| 3918 | \ 'sIc', 'sIe', 'sIg', 'sIi', 'sI', 'sIn', 'sIp', 'sIl', 'sIr', |
| 3919 | \ 'src', 'srg', 'sri', 'srI', 'srn', 'srp', 'srl', 'sr'] |
| 3920 | call feedkeys(':' .. cmd .. " \<Tab>\<C-B>\"\<CR>", 'tx') |
| 3921 | call assert_equal('"' .. cmd .. " \<Tab>", @:) |
| 3922 | endfor |
| 3923 | endfunc |
| 3924 | |
Ruslan Russkikh | 0407d62 | 2024-10-08 22:21:05 +0200 | [diff] [blame] | 3925 | " Test for shellcmdline command argument completion |
| 3926 | func Test_cmdline_complete_shellcmdline_argument() |
| 3927 | command -nargs=+ -complete=shellcmdline MyCmd |
| 3928 | |
| 3929 | set wildoptions=fuzzy |
| 3930 | |
| 3931 | call feedkeys(":MyCmd vim test_cmdline.\<Tab>\<C-B>\"\<CR>", 'xt') |
| 3932 | call assert_equal('"MyCmd vim test_cmdline.vim', @:) |
zeertzjq | 85f36d6 | 2024-10-10 19:14:13 +0200 | [diff] [blame] | 3933 | call assert_equal(['test_cmdline.vim'], |
| 3934 | \ getcompletion('vim test_cmdline.', 'shellcmdline')) |
Ruslan Russkikh | 0407d62 | 2024-10-08 22:21:05 +0200 | [diff] [blame] | 3935 | |
| 3936 | call feedkeys(":MyCmd vim nonexistentfile\<Tab>\<C-B>\"\<CR>", 'xt') |
| 3937 | call assert_equal('"MyCmd vim nonexistentfile', @:) |
zeertzjq | 85f36d6 | 2024-10-10 19:14:13 +0200 | [diff] [blame] | 3938 | call assert_equal([], |
| 3939 | \ getcompletion('vim nonexistentfile', 'shellcmdline')) |
Ruslan Russkikh | 0407d62 | 2024-10-08 22:21:05 +0200 | [diff] [blame] | 3940 | |
| 3941 | let compl1 = getcompletion('', 'file')[0] |
| 3942 | let compl2 = getcompletion('', 'file')[1] |
| 3943 | call feedkeys(":MyCmd vim \<Tab>\<C-B>\"\<CR>", 'xt') |
| 3944 | call assert_equal('"MyCmd vim ' .. compl1, @:) |
| 3945 | |
| 3946 | call feedkeys(":MyCmd vim \<Tab> \<Tab>\<C-B>\"\<CR>", 'xt') |
| 3947 | call assert_equal('"MyCmd vim ' .. compl1 .. ' ' .. compl1, @:) |
| 3948 | |
| 3949 | let compl = getcompletion('', 'file')[1] |
| 3950 | call feedkeys(":MyCmd vim \<Tab> \<Tab>\<Tab>\<C-B>\"\<CR>", 'xt') |
| 3951 | call assert_equal('"MyCmd vim ' .. compl1 .. ' ' .. compl2, @:) |
| 3952 | |
| 3953 | set wildoptions& |
| 3954 | call feedkeys(":MyCmd vim test_cmdline.\<Tab>\<C-B>\"\<CR>", 'xt') |
| 3955 | call assert_equal('"MyCmd vim test_cmdline.vim', @:) |
zeertzjq | 85f36d6 | 2024-10-10 19:14:13 +0200 | [diff] [blame] | 3956 | call assert_equal(['test_cmdline.vim'], |
| 3957 | \ getcompletion('vim test_cmdline.', 'shellcmdline')) |
Ruslan Russkikh | 0407d62 | 2024-10-08 22:21:05 +0200 | [diff] [blame] | 3958 | |
| 3959 | call feedkeys(":MyCmd vim nonexistentfile\<Tab>\<C-B>\"\<CR>", 'xt') |
| 3960 | call assert_equal('"MyCmd vim nonexistentfile', @:) |
zeertzjq | 85f36d6 | 2024-10-10 19:14:13 +0200 | [diff] [blame] | 3961 | call assert_equal([], |
| 3962 | \ getcompletion('vim nonexistentfile', 'shellcmdline')) |
Ruslan Russkikh | 0407d62 | 2024-10-08 22:21:05 +0200 | [diff] [blame] | 3963 | |
| 3964 | let compl1 = getcompletion('', 'file')[0] |
| 3965 | let compl2 = getcompletion('', 'file')[1] |
| 3966 | call feedkeys(":MyCmd vim \<Tab>\<C-B>\"\<CR>", 'xt') |
| 3967 | call assert_equal('"MyCmd vim ' .. compl1, @:) |
| 3968 | |
| 3969 | call feedkeys(":MyCmd vim \<Tab> \<Tab>\<C-B>\"\<CR>", 'xt') |
| 3970 | call assert_equal('"MyCmd vim ' .. compl1 .. ' ' .. compl1, @:) |
| 3971 | |
| 3972 | let compl = getcompletion('', 'file')[1] |
| 3973 | call feedkeys(":MyCmd vim \<Tab> \<Tab>\<Tab>\<C-B>\"\<CR>", 'xt') |
| 3974 | call assert_equal('"MyCmd vim ' .. compl1 .. ' ' .. compl2, @:) |
| 3975 | |
| 3976 | delcommand MyCmd |
| 3977 | endfunc |
| 3978 | |
Yegappan Lakshmanan | 7db3a8e | 2022-07-26 22:01:36 +0100 | [diff] [blame] | 3979 | " Test for :! shell command argument completion |
| 3980 | func Test_cmdline_complete_bang_cmd_argument() |
| 3981 | set wildoptions=fuzzy |
| 3982 | call feedkeys(":!vim test_cmdline.\<Tab>\<C-B>\"\<CR>", 'xt') |
| 3983 | call assert_equal('"!vim test_cmdline.vim', @:) |
| 3984 | set wildoptions& |
| 3985 | call feedkeys(":!vim test_cmdline.\<Tab>\<C-B>\"\<CR>", 'xt') |
| 3986 | call assert_equal('"!vim test_cmdline.vim', @:) |
| 3987 | endfunc |
| 3988 | |
zeertzjq | 961b2e5 | 2023-04-17 15:53:24 +0100 | [diff] [blame] | 3989 | func Call_cmd_funcs() |
Ruslan Russkikh | 0407d62 | 2024-10-08 22:21:05 +0200 | [diff] [blame] | 3990 | return [getcmdpos(), getcmdscreenpos(), getcmdcompltype(), getcmdcomplpat()] |
Shougo Matsushita | 79d599b | 2022-05-07 12:48:29 +0100 | [diff] [blame] | 3991 | endfunc |
| 3992 | |
| 3993 | func Test_screenpos_and_completion() |
zeertzjq | 961b2e5 | 2023-04-17 15:53:24 +0100 | [diff] [blame] | 3994 | call assert_equal(0, getcmdpos()) |
| 3995 | call assert_equal(0, getcmdscreenpos()) |
| 3996 | call assert_equal('', getcmdcompltype()) |
Ruslan Russkikh | 0407d62 | 2024-10-08 22:21:05 +0200 | [diff] [blame] | 3997 | call assert_equal('', getcmdcomplpat()) |
zeertzjq | 961b2e5 | 2023-04-17 15:53:24 +0100 | [diff] [blame] | 3998 | |
zeertzjq | a821b60 | 2024-06-18 20:31:08 +0200 | [diff] [blame] | 3999 | cnoremap <expr> <F2> string(Call_cmd_funcs()) |
zeertzjq | 961b2e5 | 2023-04-17 15:53:24 +0100 | [diff] [blame] | 4000 | call feedkeys(":let a\<F2>\<C-B>\"\<CR>", "xt") |
Ruslan Russkikh | 0407d62 | 2024-10-08 22:21:05 +0200 | [diff] [blame] | 4001 | call assert_equal("\"let a[6, 7, 'var', 'a']", @:) |
zeertzjq | 961b2e5 | 2023-04-17 15:53:24 +0100 | [diff] [blame] | 4002 | call feedkeys(":quit \<F2>\<C-B>\"\<CR>", "xt") |
Ruslan Russkikh | 0407d62 | 2024-10-08 22:21:05 +0200 | [diff] [blame] | 4003 | call assert_equal("\"quit [6, 7, '', '']", @:) |
zeertzjq | 961b2e5 | 2023-04-17 15:53:24 +0100 | [diff] [blame] | 4004 | call feedkeys(":nosuchcommand \<F2>\<C-B>\"\<CR>", "xt") |
Ruslan Russkikh | 0407d62 | 2024-10-08 22:21:05 +0200 | [diff] [blame] | 4005 | call assert_equal("\"nosuchcommand [15, 16, '', '']", @:) |
zeertzjq | a821b60 | 2024-06-18 20:31:08 +0200 | [diff] [blame] | 4006 | |
Ruslan Russkikh | 0407d62 | 2024-10-08 22:21:05 +0200 | [diff] [blame] | 4007 | " Check that getcmdcompltype() and getcmdcomplpat() don't interfere with |
| 4008 | " cmdline completion. |
zeertzjq | a821b60 | 2024-06-18 20:31:08 +0200 | [diff] [blame] | 4009 | let g:results = [] |
| 4010 | cnoremap <F2> <Cmd>let g:results += [[getcmdline()] + Call_cmd_funcs()]<CR> |
| 4011 | call feedkeys(":sign un\<Tab>\<F2>\<Tab>\<F2>\<Tab>\<F2>\<C-C>", "xt") |
| 4012 | call assert_equal([ |
Ruslan Russkikh | 0407d62 | 2024-10-08 22:21:05 +0200 | [diff] [blame] | 4013 | \ ['sign undefine', 14, 15, 'sign', 'undefine'], |
| 4014 | \ ['sign unplace', 13, 14, 'sign', 'unplace'], |
| 4015 | \ ['sign un', 8, 9, 'sign', 'un']], g:results) |
zeertzjq | a821b60 | 2024-06-18 20:31:08 +0200 | [diff] [blame] | 4016 | |
| 4017 | unlet g:results |
zeertzjq | 961b2e5 | 2023-04-17 15:53:24 +0100 | [diff] [blame] | 4018 | cunmap <F2> |
Shougo Matsushita | 79d599b | 2022-05-07 12:48:29 +0100 | [diff] [blame] | 4019 | endfunc |
| 4020 | |
Bram Moolenaar | 51f0bfb | 2022-05-17 20:11:02 +0100 | [diff] [blame] | 4021 | func Test_recursive_register() |
| 4022 | let @= = '' |
| 4023 | silent! ?e/ |
| 4024 | let caught = 'no' |
| 4025 | try |
| 4026 | normal // |
| 4027 | catch /E169:/ |
| 4028 | let caught = 'yes' |
| 4029 | endtry |
| 4030 | call assert_equal('yes', caught) |
| 4031 | endfunc |
| 4032 | |
Bram Moolenaar | 44a3f33 | 2022-06-06 15:38:21 +0100 | [diff] [blame] | 4033 | func Test_long_error_message() |
| 4034 | " the error should be truncated, not overrun IObuff |
| 4035 | silent! norm Q00000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 |
| 4036 | endfunc |
| 4037 | |
zeertzjq | 6791adc | 2022-07-26 20:42:25 +0100 | [diff] [blame] | 4038 | func Test_cmdline_redraw_tabline() |
| 4039 | CheckRunVimInTerminal |
| 4040 | |
| 4041 | let lines =<< trim END |
| 4042 | set showtabline=2 |
| 4043 | autocmd CmdlineEnter * set tabline=foo |
| 4044 | END |
Bram Moolenaar | 45bbaef | 2022-09-08 16:39:22 +0100 | [diff] [blame] | 4045 | call writefile(lines, 'Xcmdline_redraw_tabline', 'D') |
zeertzjq | 6791adc | 2022-07-26 20:42:25 +0100 | [diff] [blame] | 4046 | let buf = RunVimInTerminal('-S Xcmdline_redraw_tabline', #{rows: 6}) |
| 4047 | call term_sendkeys(buf, ':') |
| 4048 | call WaitForAssert({-> assert_match('^foo', term_getline(buf, 1))}) |
| 4049 | |
| 4050 | call StopVimInTerminal(buf) |
zeertzjq | 6791adc | 2022-07-26 20:42:25 +0100 | [diff] [blame] | 4051 | endfunc |
| 4052 | |
zeertzjq | b82a2ab | 2022-08-21 14:33:57 +0100 | [diff] [blame] | 4053 | func Test_wildmenu_pum_disable_while_shown() |
| 4054 | set wildoptions=pum |
| 4055 | set wildmenu |
| 4056 | cnoremap <F2> <Cmd>set nowildmenu<CR> |
| 4057 | call feedkeys(":sign \<Tab>\<F2>\<Esc>", 'tx') |
| 4058 | call assert_equal(0, pumvisible()) |
| 4059 | cunmap <F2> |
| 4060 | set wildoptions& wildmenu& |
| 4061 | endfunc |
| 4062 | |
Shougo Matsushita | 07ea5f1 | 2022-08-27 12:22:25 +0100 | [diff] [blame] | 4063 | func Test_setcmdline() |
| 4064 | func SetText(text, pos) |
zeertzjq | ac6cd31 | 2023-04-12 16:21:14 +0100 | [diff] [blame] | 4065 | call assert_equal(0, setcmdline(test_null_string())) |
| 4066 | call assert_equal('', getcmdline()) |
| 4067 | call assert_equal(1, getcmdpos()) |
| 4068 | |
| 4069 | call assert_equal(0, setcmdline(''[: -1])) |
| 4070 | call assert_equal('', getcmdline()) |
| 4071 | call assert_equal(1, getcmdpos()) |
| 4072 | |
zeertzjq | 54acb90 | 2022-08-29 16:21:25 +0100 | [diff] [blame] | 4073 | autocmd CmdlineChanged * let g:cmdtype = expand('<afile>') |
Shougo Matsushita | 07ea5f1 | 2022-08-27 12:22:25 +0100 | [diff] [blame] | 4074 | call assert_equal(0, setcmdline(a:text)) |
| 4075 | call assert_equal(a:text, getcmdline()) |
| 4076 | call assert_equal(len(a:text) + 1, getcmdpos()) |
zeertzjq | 54acb90 | 2022-08-29 16:21:25 +0100 | [diff] [blame] | 4077 | call assert_equal(getcmdtype(), g:cmdtype) |
| 4078 | unlet g:cmdtype |
| 4079 | autocmd! CmdlineChanged |
Shougo Matsushita | 07ea5f1 | 2022-08-27 12:22:25 +0100 | [diff] [blame] | 4080 | |
| 4081 | call assert_equal(0, setcmdline(a:text, a:pos)) |
| 4082 | call assert_equal(a:text, getcmdline()) |
| 4083 | call assert_equal(a:pos, getcmdpos()) |
| 4084 | |
| 4085 | call assert_fails('call setcmdline("' .. a:text .. '", -1)', 'E487:') |
Yegappan Lakshmanan | 25f1e55 | 2022-08-28 17:25:04 +0100 | [diff] [blame] | 4086 | call assert_fails('call setcmdline({}, 0)', 'E1174:') |
| 4087 | call assert_fails('call setcmdline("' .. a:text .. '", {})', 'E1210:') |
Shougo Matsushita | 07ea5f1 | 2022-08-27 12:22:25 +0100 | [diff] [blame] | 4088 | |
| 4089 | return '' |
| 4090 | endfunc |
| 4091 | |
| 4092 | call feedkeys(":\<C-R>=SetText('set rtp?', 2)\<CR>\<CR>", 'xt') |
| 4093 | call assert_equal('set rtp?', @:) |
| 4094 | |
zeertzjq | 54acb90 | 2022-08-29 16:21:25 +0100 | [diff] [blame] | 4095 | call feedkeys(":let g:str = input('? ')\<CR>", 't') |
| 4096 | call feedkeys("\<C-R>=SetText('foo', 4)\<CR>\<CR>", 'xt') |
| 4097 | call assert_equal('foo', g:str) |
| 4098 | unlet g:str |
| 4099 | |
| 4100 | delfunc SetText |
| 4101 | |
Shougo Matsushita | 07ea5f1 | 2022-08-27 12:22:25 +0100 | [diff] [blame] | 4102 | " setcmdline() returns 1 when not editing the command line. |
| 4103 | call assert_equal(1, 'foo'->setcmdline()) |
| 4104 | |
| 4105 | " Called in custom function |
| 4106 | func CustomComplete(A, L, P) |
| 4107 | call assert_equal(0, setcmdline("DoCmd ")) |
| 4108 | return "January\nFebruary\nMars\n" |
| 4109 | endfunc |
| 4110 | |
| 4111 | com! -nargs=* -complete=custom,CustomComplete DoCmd : |
| 4112 | call feedkeys(":DoCmd \<C-A>\<C-B>\"\<CR>", 'tx') |
| 4113 | call assert_equal('"DoCmd January February Mars', @:) |
zeertzjq | 54acb90 | 2022-08-29 16:21:25 +0100 | [diff] [blame] | 4114 | delcom DoCmd |
| 4115 | delfunc CustomComplete |
Shougo Matsushita | 07ea5f1 | 2022-08-27 12:22:25 +0100 | [diff] [blame] | 4116 | |
| 4117 | " Called in <expr> |
| 4118 | cnoremap <expr>a setcmdline('let foo=') |
| 4119 | call feedkeys(":a\<CR>", 'tx') |
| 4120 | call assert_equal('let foo=0', @:) |
| 4121 | cunmap a |
| 4122 | endfunc |
| 4123 | |
Sean Dewar | fc8a601 | 2023-04-17 16:41:20 +0100 | [diff] [blame] | 4124 | func Test_rulerformat_position() |
| 4125 | CheckScreendump |
| 4126 | |
| 4127 | let buf = RunVimInTerminal('', #{rows: 2, cols: 20}) |
| 4128 | call term_sendkeys(buf, ":set ruler rulerformat=longish\<CR>") |
| 4129 | call term_sendkeys(buf, ":set laststatus=0 winwidth=1\<CR>") |
| 4130 | call term_sendkeys(buf, "\<C-W>v\<C-W>|\<C-W>p") |
| 4131 | call VerifyScreenDump(buf, 'Test_rulerformat_position', {}) |
| 4132 | |
| 4133 | " clean up |
| 4134 | call StopVimInTerminal(buf) |
| 4135 | endfunc |
| 4136 | |
Yegappan Lakshmanan | ac023e8 | 2024-11-27 20:55:45 +0100 | [diff] [blame] | 4137 | " Test for using "%!" in 'rulerformat' to use a function |
| 4138 | func Test_rulerformat_function() |
| 4139 | CheckScreendump |
| 4140 | |
| 4141 | let lines =<< trim END |
| 4142 | func TestRulerFn() |
| 4143 | return '10,20%=30%%' |
| 4144 | endfunc |
| 4145 | END |
| 4146 | call writefile(lines, 'Xrulerformat_function', 'D') |
| 4147 | |
| 4148 | let buf = RunVimInTerminal('-S Xrulerformat_function', #{rows: 2, cols: 40}) |
| 4149 | call term_sendkeys(buf, ":set ruler rulerformat=%!TestRulerFn()\<CR>") |
| 4150 | call term_sendkeys(buf, ":redraw!\<CR>") |
| 4151 | call term_wait(buf) |
| 4152 | call VerifyScreenDump(buf, 'Test_rulerformat_function', {}) |
| 4153 | |
| 4154 | " clean up |
| 4155 | call StopVimInTerminal(buf) |
| 4156 | endfunc |
| 4157 | |
zeertzjq | e4c79d3 | 2023-08-15 22:41:53 +0200 | [diff] [blame] | 4158 | func Test_getcompletion_usercmd() |
Christian Brabandt | 8ef1fbc | 2023-07-17 20:09:37 +0200 | [diff] [blame] | 4159 | command! -nargs=* -complete=command TestCompletion echo <q-args> |
Christian Brabandt | 8ef1fbc | 2023-07-17 20:09:37 +0200 | [diff] [blame] | 4160 | |
zeertzjq | e4c79d3 | 2023-08-15 22:41:53 +0200 | [diff] [blame] | 4161 | call assert_equal(getcompletion('', 'cmdline'), |
| 4162 | \ getcompletion('TestCompletion ', 'cmdline')) |
| 4163 | call assert_equal(['<buffer>'], |
| 4164 | \ getcompletion('TestCompletion map <bu', 'cmdline')) |
| 4165 | |
Christian Brabandt | 8ef1fbc | 2023-07-17 20:09:37 +0200 | [diff] [blame] | 4166 | delcom TestCompletion |
Christian Brabandt | 8ef1fbc | 2023-07-17 20:09:37 +0200 | [diff] [blame] | 4167 | endfunc |
zeertzjq | e4c79d3 | 2023-08-15 22:41:53 +0200 | [diff] [blame] | 4168 | |
Shougo Matsushita | 92997dd | 2023-08-20 20:55:55 +0200 | [diff] [blame] | 4169 | func Test_custom_completion() |
| 4170 | func CustomComplete1(lead, line, pos) |
| 4171 | return "a\nb\nc" |
| 4172 | endfunc |
| 4173 | func CustomComplete2(lead, line, pos) |
| 4174 | return ['a', 'b']->filter({ _, val -> val->stridx(a:lead) == 0 }) |
| 4175 | endfunc |
| 4176 | func Check_custom_completion() |
| 4177 | call assert_equal('custom,CustomComplete1', getcmdcompltype()) |
| 4178 | return '' |
| 4179 | endfunc |
| 4180 | func Check_customlist_completion() |
| 4181 | call assert_equal('customlist,CustomComplete2', getcmdcompltype()) |
| 4182 | return '' |
| 4183 | endfunc |
| 4184 | |
| 4185 | command -nargs=1 -complete=custom,CustomComplete1 Test1 echo |
| 4186 | command -nargs=1 -complete=customlist,CustomComplete2 Test2 echo |
| 4187 | |
| 4188 | call feedkeys(":Test1 \<C-R>=Check_custom_completion()\<CR>\<Esc>", "xt") |
| 4189 | call feedkeys(":Test2 \<C-R>=Check_customlist_completion()\<CR>\<Esc>", "xt") |
| 4190 | |
| 4191 | call assert_fails("call getcompletion('', 'custom')", 'E475:') |
| 4192 | call assert_fails("call getcompletion('', 'customlist')", 'E475:') |
| 4193 | |
zeertzjq | 757f321 | 2024-04-15 19:01:04 +0200 | [diff] [blame] | 4194 | call assert_equal(['a', 'b', 'c'], getcompletion('', 'custom,CustomComplete1')) |
| 4195 | call assert_equal(['a', 'b'], getcompletion('', 'customlist,CustomComplete2')) |
| 4196 | call assert_equal(['b'], getcompletion('b', 'customlist,CustomComplete2')) |
Shougo Matsushita | 92997dd | 2023-08-20 20:55:55 +0200 | [diff] [blame] | 4197 | |
| 4198 | delcom Test1 |
| 4199 | delcom Test2 |
| 4200 | |
| 4201 | delfunc CustomComplete1 |
| 4202 | delfunc CustomComplete2 |
| 4203 | delfunc Check_custom_completion |
| 4204 | delfunc Check_customlist_completion |
| 4205 | endfunc |
| 4206 | |
zeertzjq | 28a2360 | 2023-09-29 19:58:35 +0200 | [diff] [blame] | 4207 | func Test_custom_completion_with_glob() |
| 4208 | func TestGlobComplete(A, L, P) |
| 4209 | return split(glob('Xglob*'), "\n") |
| 4210 | endfunc |
| 4211 | |
| 4212 | command -nargs=* -complete=customlist,TestGlobComplete TestGlobComplete : |
| 4213 | call writefile([], 'Xglob1', 'D') |
| 4214 | call writefile([], 'Xglob2', 'D') |
| 4215 | |
| 4216 | call feedkeys(":TestGlobComplete \<Tab> \<Tab>\<C-N> \<Tab>\<C-P>;\<C-B>\"\<CR>", 'xt') |
| 4217 | call assert_equal('"TestGlobComplete Xglob1 Xglob2 ;', @:) |
| 4218 | |
| 4219 | delcommand TestGlobComplete |
| 4220 | delfunc TestGlobComplete |
| 4221 | endfunc |
| 4222 | |
Christian Brabandt | 8610f74 | 2024-01-12 17:34:40 +0100 | [diff] [blame] | 4223 | func Test_window_size_stays_same_after_changing_cmdheight() |
| 4224 | set laststatus=2 |
| 4225 | let expected = winheight(0) |
| 4226 | function! Function_name() abort |
| 4227 | call feedkeys(":"..repeat('x', &columns), 'x') |
| 4228 | let &cmdheight=2 |
| 4229 | let &cmdheight=1 |
| 4230 | redraw |
| 4231 | endfunction |
| 4232 | call Function_name() |
| 4233 | call assert_equal(expected, winheight(0)) |
| 4234 | endfunc |
| 4235 | |
Christian Brabandt | 0dc0bff | 2024-02-24 14:12:13 +0100 | [diff] [blame] | 4236 | " verify that buffer-completion finds all buffer names matching a pattern |
| 4237 | func Test_buffer_completion() |
| 4238 | " should return empty list |
| 4239 | call assert_equal([], getcompletion('', 'buffer')) |
| 4240 | |
| 4241 | call mkdir('Xbuf_complete', 'R') |
| 4242 | e Xbuf_complete/Foobar.c |
| 4243 | e Xbuf_complete/MyFoobar.c |
| 4244 | e AFoobar.h |
| 4245 | let expected = ["Xbuf_complete/Foobar.c", "Xbuf_complete/MyFoobar.c", "AFoobar.h"] |
| 4246 | |
| 4247 | call assert_equal(3, len(getcompletion('Foo', 'buffer'))) |
| 4248 | call assert_equal(expected, getcompletion('Foo', 'buffer')) |
| 4249 | call feedkeys(":b Foo\<C-A>\<C-B>\"\<CR>", 'xt') |
| 4250 | call assert_equal("\"b Xbuf_complete/Foobar.c Xbuf_complete/MyFoobar.c AFoobar.h", @:) |
| 4251 | endfunc |
| 4252 | |
Anton Sharonov | 49528da | 2024-04-14 20:02:24 +0200 | [diff] [blame] | 4253 | " :set t_?? |
| 4254 | func Test_term_option() |
| 4255 | set wildoptions& |
| 4256 | let _cpo = &cpo |
| 4257 | set cpo-=C |
Christian Brabandt | 0d87e3c | 2024-04-14 23:14:50 +0200 | [diff] [blame] | 4258 | " There may be more, test only until t_xo |
Anton Sharonov | 49528da | 2024-04-14 20:02:24 +0200 | [diff] [blame] | 4259 | let expected='"set t_AB t_AF t_AU t_AL t_al t_bc t_BE t_BD t_cd t_ce t_Ce t_CF t_cl t_cm' |
| 4260 | \ .. ' t_Co t_CS t_Cs t_cs t_CV t_da t_db t_DL t_dl t_ds t_Ds t_EC t_EI t_fs t_fd t_fe' |
| 4261 | \ .. ' t_GP t_IE t_IS t_ke t_ks t_le t_mb t_md t_me t_mr t_ms t_nd t_op t_RF t_RB t_RC' |
| 4262 | \ .. ' t_RI t_Ri t_RK t_RS t_RT t_RV t_Sb t_SC t_se t_Sf t_SH t_SI t_Si t_so t_SR t_sr' |
| 4263 | \ .. ' t_ST t_Te t_te t_TE t_ti t_TI t_Ts t_ts t_u7 t_ue t_us t_Us t_ut t_vb t_ve t_vi' |
Christian Brabandt | 0d87e3c | 2024-04-14 23:14:50 +0200 | [diff] [blame] | 4264 | \ .. ' t_VS t_vs t_WP t_WS t_XM t_xn t_xs t_ZH t_ZR t_8f t_8b t_8u t_xo .*' |
Anton Sharonov | 49528da | 2024-04-14 20:02:24 +0200 | [diff] [blame] | 4265 | call feedkeys(":set t_\<C-A>\<C-B>\"\<CR>", 'tx') |
Christian Brabandt | 0d87e3c | 2024-04-14 23:14:50 +0200 | [diff] [blame] | 4266 | call assert_match(expected, @:) |
Anton Sharonov | 49528da | 2024-04-14 20:02:24 +0200 | [diff] [blame] | 4267 | let &cpo = _cpo |
| 4268 | endfunc |
| 4269 | |
Christian Brabandt | 70a11a6 | 2024-07-26 19:13:55 +0200 | [diff] [blame] | 4270 | func Test_ex_command_completion() |
| 4271 | " required for :* |
| 4272 | set cpo+=* |
| 4273 | let list = filter(getcompletion('', 'command'), 'exists(":" . v:val) == 0') |
Hirohito Higashi | fbe4a8f | 2025-04-27 15:28:30 +0200 | [diff] [blame] | 4274 | " :++ and :-- are only valid in Vim9 script context, so they can be ignored |
Christian Brabandt | 70a11a6 | 2024-07-26 19:13:55 +0200 | [diff] [blame] | 4275 | call assert_equal(['++', '--'], sort(list)) |
Doug Kearns | ea84202 | 2024-09-29 17:17:41 +0200 | [diff] [blame] | 4276 | call assert_equal(2, exists(':k')) |
Christian Brabandt | 70a11a6 | 2024-07-26 19:13:55 +0200 | [diff] [blame] | 4277 | call assert_equal(0, exists(':ke')) |
| 4278 | call assert_equal(1, exists(':kee')) |
| 4279 | call assert_equal(1, exists(':keep')) |
| 4280 | call assert_equal(1, exists(':keepm')) |
| 4281 | call assert_equal(1, exists(':keepma')) |
| 4282 | call assert_equal(1, exists(':keepmar')) |
| 4283 | call assert_equal(1, exists(':keepmark')) |
| 4284 | call assert_equal(2, exists(':keepmarks')) |
| 4285 | call assert_equal(2, exists(':keepalt')) |
| 4286 | call assert_equal(2, exists(':keepjumps')) |
| 4287 | call assert_equal(2, exists(':keeppatterns')) |
| 4288 | set cpo-=* |
| 4289 | endfunc |
| 4290 | |
zeertzjq | 5df3cb2 | 2024-10-07 21:05:06 +0200 | [diff] [blame] | 4291 | func Test_cd_bslash_completion_windows() |
Christian Brabandt | 1a31c43 | 2024-10-06 16:34:20 +0200 | [diff] [blame] | 4292 | CheckMSWindows |
| 4293 | let save_shellslash = &shellslash |
| 4294 | set noshellslash |
| 4295 | call system('mkdir XXXa\_b') |
| 4296 | defer delete('XXXa', 'rf') |
| 4297 | call feedkeys(":cd XXXa\\_b\<C-A>\<C-B>\"\<CR>", 'tx') |
| 4298 | call assert_equal('"cd XXXa\_b\', @:) |
| 4299 | let &shellslash = save_shellslash |
| 4300 | endfunc |
| 4301 | |
zeertzjq | ec270a5 | 2025-04-23 20:50:23 +0200 | [diff] [blame] | 4302 | " Test cmdcomplete_info() with CmdlineLeavePre autocmd |
Girish Palya | 92f68e2 | 2025-04-21 11:12:41 +0200 | [diff] [blame] | 4303 | func Test_cmdcomplete_info() |
| 4304 | augroup test_CmdlineLeavePre |
| 4305 | autocmd! |
zeertzjq | ec270a5 | 2025-04-23 20:50:23 +0200 | [diff] [blame] | 4306 | " Calling expand() should not interfere with cmdcomplete_info(). |
| 4307 | autocmd CmdlineLeavePre * call expand('test_cmdline.*') |
Girish Palya | 92f68e2 | 2025-04-21 11:12:41 +0200 | [diff] [blame] | 4308 | autocmd CmdlineLeavePre * let g:cmdcomplete_info = string(cmdcomplete_info()) |
| 4309 | augroup END |
| 4310 | new |
| 4311 | call assert_equal({}, cmdcomplete_info()) |
| 4312 | call feedkeys(":h echom\<cr>", "tx") " No expansion |
| 4313 | call assert_equal('{}', g:cmdcomplete_info) |
| 4314 | call feedkeys(":h echoms\<tab>\<cr>", "tx") |
| 4315 | call assert_equal('{''cmdline_orig'': '''', ''pum_visible'': 0, ''matches'': [], ''selected'': 0}', g:cmdcomplete_info) |
| 4316 | call feedkeys(":h echom\<tab>\<cr>", "tx") |
| 4317 | call assert_equal( |
| 4318 | \ '{''cmdline_orig'': ''h echom'', ''pum_visible'': 0, ''matches'': ['':echom'', '':echomsg''], ''selected'': 0}', |
| 4319 | \ g:cmdcomplete_info) |
| 4320 | call feedkeys(":h echom\<tab>\<tab>\<cr>", "tx") |
| 4321 | call assert_equal( |
| 4322 | \ '{''cmdline_orig'': ''h echom'', ''pum_visible'': 0, ''matches'': ['':echom'', '':echomsg''], ''selected'': 1}', |
| 4323 | \ g:cmdcomplete_info) |
| 4324 | call feedkeys(":h echom\<tab>\<tab>\<tab>\<cr>", "tx") |
| 4325 | call assert_equal( |
| 4326 | \ '{''cmdline_orig'': ''h echom'', ''pum_visible'': 0, ''matches'': ['':echom'', '':echomsg''], ''selected'': -1}', |
| 4327 | \ g:cmdcomplete_info) |
| 4328 | |
| 4329 | set wildoptions=pum |
| 4330 | call feedkeys(":h echoms\<tab>\<cr>", "tx") |
| 4331 | call assert_equal('{''cmdline_orig'': '''', ''pum_visible'': 0, ''matches'': [], ''selected'': 0}', g:cmdcomplete_info) |
| 4332 | call feedkeys(":h echom\<tab>\<cr>", "tx") |
| 4333 | call assert_equal( |
| 4334 | \ '{''cmdline_orig'': ''h echom'', ''pum_visible'': 1, ''matches'': ['':echom'', '':echomsg''], ''selected'': 0}', |
| 4335 | \ g:cmdcomplete_info) |
| 4336 | call feedkeys(":h echom\<tab>\<tab>\<cr>", "tx") |
| 4337 | call assert_equal( |
| 4338 | \ '{''cmdline_orig'': ''h echom'', ''pum_visible'': 1, ''matches'': ['':echom'', '':echomsg''], ''selected'': 1}', |
| 4339 | \ g:cmdcomplete_info) |
| 4340 | call feedkeys(":h echom\<tab>\<tab>\<tab>\<cr>", "tx") |
| 4341 | call assert_equal( |
| 4342 | \ '{''cmdline_orig'': ''h echom'', ''pum_visible'': 1, ''matches'': ['':echom'', '':echomsg''], ''selected'': -1}', |
| 4343 | \ g:cmdcomplete_info) |
| 4344 | bw! |
| 4345 | set wildoptions& |
| 4346 | endfunc |
| 4347 | |
Naruhiko Nishino | be5bd4d | 2025-05-14 21:20:28 +0200 | [diff] [blame] | 4348 | func Test_redrawtabpanel_error() |
| 4349 | CheckNotFeature tabpanel |
| 4350 | call assert_fails(':redrawtabpanel', 'E1547:') |
| 4351 | endfunc |
| 4352 | |
Bram Moolenaar | 309976e | 2019-12-05 18:16:33 +0100 | [diff] [blame] | 4353 | " vim: shiftwidth=2 sts=2 expandtab |