comparison src/testdir/test_cmdline.vim @ 23748:93f90f2ff4e9 v8.2.2415

patch 8.2.2415: no way to check for the cmdwin feature Commit: https://github.com/vim/vim/commit/21829c5f2c86cd525c8468121b4fc54c5d75bf6e Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jan 26 22:42:21 2021 +0100 patch 8.2.2415: no way to check for the cmdwin feature Problem: No way to check for the cmdwin feature, cmdline_hist is now always enabled. Solution: Add has('cmdwin') support. Skip arglist test on Windows temporarily.
author Bram Moolenaar <Bram@vim.org>
date Tue, 26 Jan 2021 22:45:04 +0100
parents a9433f834693
children 34a95c4bd647
comparison
equal deleted inserted replaced
23747:f0d11de94492 23748:93f90f2ff4e9
127 call StopVimInTerminal(buf) 127 call StopVimInTerminal(buf)
128 call delete('XTest_wildmenu') 128 call delete('XTest_wildmenu')
129 endfunc 129 endfunc
130 130
131 func Test_map_completion() 131 func Test_map_completion()
132 CheckFeature cmdline_compl
133 call feedkeys(":map <unique> <si\<Tab>\<Home>\"\<CR>", 'xt') 132 call feedkeys(":map <unique> <si\<Tab>\<Home>\"\<CR>", 'xt')
134 call assert_equal('"map <unique> <silent>', getreg(':')) 133 call assert_equal('"map <unique> <silent>', getreg(':'))
135 call feedkeys(":map <script> <un\<Tab>\<Home>\"\<CR>", 'xt') 134 call feedkeys(":map <script> <un\<Tab>\<Home>\"\<CR>", 'xt')
136 call assert_equal('"map <script> <unique>', getreg(':')) 135 call assert_equal('"map <script> <unique>', getreg(':'))
137 call feedkeys(":map <expr> <sc\<Tab>\<Home>\"\<CR>", 'xt') 136 call feedkeys(":map <expr> <sc\<Tab>\<Home>\"\<CR>", 'xt')
205 unmap <Middle>x 204 unmap <Middle>x
206 set cpo&vim 205 set cpo&vim
207 endfunc 206 endfunc
208 207
209 func Test_match_completion() 208 func Test_match_completion()
210 CheckFeature cmdline_compl
211 hi Aardig ctermfg=green 209 hi Aardig ctermfg=green
212 call feedkeys(":match \<Tab>\<Home>\"\<CR>", 'xt') 210 call feedkeys(":match \<Tab>\<Home>\"\<CR>", 'xt')
213 call assert_equal('"match Aardig', getreg(':')) 211 call assert_equal('"match Aardig', getreg(':'))
214 call feedkeys(":match \<S-Tab>\<Home>\"\<CR>", 'xt') 212 call feedkeys(":match \<S-Tab>\<Home>\"\<CR>", 'xt')
215 call assert_equal('"match none', getreg(':')) 213 call assert_equal('"match none', getreg(':'))
216 endfunc 214 endfunc
217 215
218 func Test_highlight_completion() 216 func Test_highlight_completion()
219 CheckFeature cmdline_compl
220 hi Aardig ctermfg=green 217 hi Aardig ctermfg=green
221 call feedkeys(":hi \<Tab>\<Home>\"\<CR>", 'xt') 218 call feedkeys(":hi \<Tab>\<Home>\"\<CR>", 'xt')
222 call assert_equal('"hi Aardig', getreg(':')) 219 call assert_equal('"hi Aardig', getreg(':'))
223 call feedkeys(":hi default \<Tab>\<Home>\"\<CR>", 'xt') 220 call feedkeys(":hi default \<Tab>\<Home>\"\<CR>", 'xt')
224 call assert_equal('"hi default Aardig', getreg(':')) 221 call assert_equal('"hi default Aardig', getreg(':'))
251 call assert_equal("\"hi Ni \<Tab>", @:) 248 call assert_equal("\"hi Ni \<Tab>", @:)
252 call test_override('ALL', 0) 249 call test_override('ALL', 0)
253 endfunc 250 endfunc
254 251
255 func Test_getcompletion() 252 func Test_getcompletion()
256 CheckFeature cmdline_compl
257 let groupcount = len(getcompletion('', 'event')) 253 let groupcount = len(getcompletion('', 'event'))
258 call assert_true(groupcount > 0) 254 call assert_true(groupcount > 0)
259 let matchcount = len('File'->getcompletion('event')) 255 let matchcount = len('File'->getcompletion('event'))
260 call assert_true(matchcount > 0) 256 call assert_true(matchcount > 0)
261 call assert_true(groupcount > matchcount) 257 call assert_true(groupcount > matchcount)
978 974
979 call assert_equal('', getcmdline()) 975 call assert_equal('', getcmdline())
980 endfunc 976 endfunc
981 977
982 func Test_getcmdwintype() 978 func Test_getcmdwintype()
979 CheckFeature cmdwin
980
983 call feedkeys("q/:let a = getcmdwintype()\<CR>:q\<CR>", 'x!') 981 call feedkeys("q/:let a = getcmdwintype()\<CR>:q\<CR>", 'x!')
984 call assert_equal('/', a) 982 call assert_equal('/', a)
985 983
986 call feedkeys("q?:let a = getcmdwintype()\<CR>:q\<CR>", 'x!') 984 call feedkeys("q?:let a = getcmdwintype()\<CR>:q\<CR>", 'x!')
987 call assert_equal('?', a) 985 call assert_equal('?', a)
994 992
995 call assert_equal('', getcmdwintype()) 993 call assert_equal('', getcmdwintype())
996 endfunc 994 endfunc
997 995
998 func Test_getcmdwin_autocmd() 996 func Test_getcmdwin_autocmd()
997 CheckFeature cmdwin
998
999 let s:seq = [] 999 let s:seq = []
1000 augroup CmdWin 1000 augroup CmdWin
1001 au WinEnter * call add(s:seq, 'WinEnter ' .. win_getid()) 1001 au WinEnter * call add(s:seq, 'WinEnter ' .. win_getid())
1002 au WinLeave * call add(s:seq, 'WinLeave ' .. win_getid()) 1002 au WinLeave * call add(s:seq, 'WinLeave ' .. win_getid())
1003 au BufEnter * call add(s:seq, 'BufEnter ' .. bufnr()) 1003 au BufEnter * call add(s:seq, 'BufEnter ' .. bufnr())
1106 1106
1107 let &encoding = encoding_save 1107 let &encoding = encoding_save
1108 endfunc 1108 endfunc
1109 1109
1110 func Test_cmdwin_bug() 1110 func Test_cmdwin_bug()
1111 CheckFeature cmdwin
1112
1111 let winid = win_getid() 1113 let winid = win_getid()
1112 sp 1114 sp
1113 try 1115 try
1114 call feedkeys("q::call win_gotoid(" .. winid .. ")\<CR>:q\<CR>", 'x!') 1116 call feedkeys("q::call win_gotoid(" .. winid .. ")\<CR>:q\<CR>", 'x!')
1115 catch /^Vim\%((\a\+)\)\=:E11/ 1117 catch /^Vim\%((\a\+)\)\=:E11/
1116 endtry 1118 endtry
1117 bw! 1119 bw!
1118 endfunc 1120 endfunc
1119 1121
1120 func Test_cmdwin_restore() 1122 func Test_cmdwin_restore()
1123 CheckFeature cmdwin
1121 CheckScreendump 1124 CheckScreendump
1122 1125
1123 let lines =<< trim [SCRIPT] 1126 let lines =<< trim [SCRIPT]
1124 call setline(1, range(30)) 1127 call setline(1, range(30))
1125 2split 1128 2split
1191 bwipeout bufb 1194 bwipeout bufb
1192 bwipeout bufc 1195 bwipeout bufc
1193 endfunc 1196 endfunc
1194 1197
1195 func Test_cmdwin_feedkeys() 1198 func Test_cmdwin_feedkeys()
1199 CheckFeature cmdwin
1200
1196 " This should not generate E488 1201 " This should not generate E488
1197 call feedkeys("q:\<CR>", 'x') 1202 call feedkeys("q:\<CR>", 'x')
1198 " Using feedkeys with q: only should automatically close the cmd window 1203 " Using feedkeys with q: only should automatically close the cmd window
1199 call feedkeys('q:', 'xt') 1204 call feedkeys('q:', 'xt')
1200 call assert_equal(1, winnr('$')) 1205 call assert_equal(1, winnr('$'))
1202 endfunc 1207 endfunc
1203 1208
1204 " Tests for the issues fixed in 7.4.441. 1209 " Tests for the issues fixed in 7.4.441.
1205 " When 'cedit' is set to Ctrl-C, opening the command window hangs Vim 1210 " When 'cedit' is set to Ctrl-C, opening the command window hangs Vim
1206 func Test_cmdwin_cedit() 1211 func Test_cmdwin_cedit()
1212 CheckFeature cmdwin
1213
1207 exe "set cedit=\<C-c>" 1214 exe "set cedit=\<C-c>"
1208 normal! : 1215 normal! :
1209 call assert_equal(1, winnr('$')) 1216 call assert_equal(1, winnr('$'))
1210 1217
1211 let g:cmd_wintype = '' 1218 let g:cmd_wintype = ''
1224 delfunc CmdWinType 1231 delfunc CmdWinType
1225 endfunc 1232 endfunc
1226 1233
1227 " Test for CmdwinEnter autocmd 1234 " Test for CmdwinEnter autocmd
1228 func Test_cmdwin_autocmd() 1235 func Test_cmdwin_autocmd()
1236 CheckFeature cmdwin
1237
1229 augroup CmdWin 1238 augroup CmdWin
1230 au! 1239 au!
1231 autocmd CmdwinEnter * startinsert 1240 autocmd CmdwinEnter * startinsert
1232 augroup END 1241 augroup END
1233 1242
1266 call assert_fails('e <abuf>', 'E496:') 1275 call assert_fails('e <abuf>', 'E496:')
1267 call assert_fails('e <amatch>', 'E497:') 1276 call assert_fails('e <amatch>', 'E497:')
1268 endfunc 1277 endfunc
1269 1278
1270 func Test_cmdwin_jump_to_win() 1279 func Test_cmdwin_jump_to_win()
1280 CheckFeature cmdwin
1281
1271 call assert_fails('call feedkeys("q:\<C-W>\<C-W>\<CR>", "xt")', 'E11:') 1282 call assert_fails('call feedkeys("q:\<C-W>\<C-W>\<CR>", "xt")', 'E11:')
1272 new 1283 new
1273 set modified 1284 set modified
1274 call assert_fails('call feedkeys("q/:qall\<CR>", "xt")', ['E37:', 'E162:']) 1285 call assert_fails('call feedkeys("q/:qall\<CR>", "xt")', ['E37:', 'E162:'])
1275 close! 1286 close!
1282 call assert_beeps('call feedkeys("q:q:\<CR>\<CR>", "xt")') 1293 call assert_beeps('call feedkeys("q:q:\<CR>\<CR>", "xt")')
1283 call assert_equal(1, winnr('$')) 1294 call assert_equal(1, winnr('$'))
1284 endfunc 1295 endfunc
1285 1296
1286 func Test_cmdwin_interrupted() 1297 func Test_cmdwin_interrupted()
1298 CheckFeature cmdwin
1287 CheckScreendump 1299 CheckScreendump
1288 1300
1289 " aborting the :smile output caused the cmdline window to use the current 1301 " aborting the :smile output caused the cmdline window to use the current
1290 " buffer. 1302 " buffer.
1291 let lines =<< trim [SCRIPT] 1303 let lines =<< trim [SCRIPT]
1568 %bwipe! 1580 %bwipe!
1569 endfunc 1581 endfunc
1570 1582
1571 " Test for recursively getting multiple command line inputs 1583 " Test for recursively getting multiple command line inputs
1572 func Test_cmdwin_multi_input() 1584 func Test_cmdwin_multi_input()
1585 CheckFeature cmdwin
1586
1573 call feedkeys(":\<C-R>=input('P: ')\<CR>\"cyan\<CR>\<CR>", 'xt') 1587 call feedkeys(":\<C-R>=input('P: ')\<CR>\"cyan\<CR>\<CR>", 'xt')
1574 call assert_equal('"cyan', @:) 1588 call assert_equal('"cyan', @:)
1575 endfunc 1589 endfunc
1576 1590
1577 " Test for using CTRL-_ in the command line with 'allowrevins' 1591 " Test for using CTRL-_ in the command line with 'allowrevins'
1592 call assert_equal('"ゔ', @:) 1606 call assert_equal('"ゔ', @:)
1593 endfunc 1607 endfunc
1594 1608
1595 " Test for normal mode commands not supported in the cmd window 1609 " Test for normal mode commands not supported in the cmd window
1596 func Test_cmdwin_blocked_commands() 1610 func Test_cmdwin_blocked_commands()
1611 CheckFeature cmdwin
1612
1597 call assert_fails('call feedkeys("q:\<C-T>\<CR>", "xt")', 'E11:') 1613 call assert_fails('call feedkeys("q:\<C-T>\<CR>", "xt")', 'E11:')
1598 call assert_fails('call feedkeys("q:\<C-]>\<CR>", "xt")', 'E11:') 1614 call assert_fails('call feedkeys("q:\<C-]>\<CR>", "xt")', 'E11:')
1599 call assert_fails('call feedkeys("q:\<C-^>\<CR>", "xt")', 'E11:') 1615 call assert_fails('call feedkeys("q:\<C-^>\<CR>", "xt")', 'E11:')
1600 call assert_fails('call feedkeys("q:Q\<CR>", "xt")', 'E11:') 1616 call assert_fails('call feedkeys("q:Q\<CR>", "xt")', 'E11:')
1601 call assert_fails('call feedkeys("q:Z\<CR>", "xt")', 'E11:') 1617 call assert_fails('call feedkeys("q:Z\<CR>", "xt")', 'E11:')
1623 call assert_fails('call feedkeys("q:\<C-W>g\<CR>", "xt")', 'E11:') 1639 call assert_fails('call feedkeys("q:\<C-W>g\<CR>", "xt")', 'E11:')
1624 endfunc 1640 endfunc
1625 1641
1626 " Close the Cmd-line window in insert mode using CTRL-C 1642 " Close the Cmd-line window in insert mode using CTRL-C
1627 func Test_cmdwin_insert_mode_close() 1643 func Test_cmdwin_insert_mode_close()
1644 CheckFeature cmdwin
1645
1628 %bw! 1646 %bw!
1629 let s = '' 1647 let s = ''
1630 exe "normal q:a\<C-C>let s='Hello'\<CR>" 1648 exe "normal q:a\<C-C>let s='Hello'\<CR>"
1631 call assert_equal('Hello', s) 1649 call assert_equal('Hello', s)
1632 call assert_equal(1, winnr('$')) 1650 call assert_equal(1, winnr('$'))