Mirror of the Vim source from https://github.com/vim/vim
Revisión | b1f345ec827eed65e58c63760f48fd739cd83faa (tree) |
---|---|
Tiempo | 2022-07-03 00:30:02 |
Autor | Bram Moolenaar <Bram@vim....> |
Commiter | Bram Moolenaar |
patch 9.0.0027: the command line test is getting quite big
Commit: https://github.com/vim/vim/commit/2d2950198231a31bf87c1cd4322099cc36b0bb93
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jul 2 16:29:34 2022 +0100
@@ -87,6 +87,7 @@ | ||
87 | 87 | test_clientserver \ |
88 | 88 | test_close_count \ |
89 | 89 | test_cmdline \ |
90 | + test_cmdwin \ | |
90 | 91 | test_command_count \ |
91 | 92 | test_comments \ |
92 | 93 | test_comparators \ |
@@ -345,6 +346,7 @@ | ||
345 | 346 | test_clientserver.res \ |
346 | 347 | test_close_count.res \ |
347 | 348 | test_cmdline.res \ |
349 | + test_cmdwin.res \ | |
348 | 350 | test_command_count.res \ |
349 | 351 | test_comments.res \ |
350 | 352 | test_comparators.res \ |
@@ -1322,57 +1322,6 @@ | ||
1322 | 1322 | call assert_equal('', getcmdline()) |
1323 | 1323 | endfunc |
1324 | 1324 | |
1325 | -func Test_getcmdwintype() | |
1326 | - CheckFeature cmdwin | |
1327 | - | |
1328 | - call feedkeys("q/:let a = getcmdwintype()\<CR>:q\<CR>", 'x!') | |
1329 | - call assert_equal('/', a) | |
1330 | - | |
1331 | - call feedkeys("q?:let a = getcmdwintype()\<CR>:q\<CR>", 'x!') | |
1332 | - call assert_equal('?', a) | |
1333 | - | |
1334 | - call feedkeys("q::let a = getcmdwintype()\<CR>:q\<CR>", 'x!') | |
1335 | - call assert_equal(':', a) | |
1336 | - | |
1337 | - call feedkeys(":\<C-F>:let a = getcmdwintype()\<CR>:q\<CR>", 'x!') | |
1338 | - call assert_equal(':', a) | |
1339 | - | |
1340 | - call assert_equal('', getcmdwintype()) | |
1341 | -endfunc | |
1342 | - | |
1343 | -func Test_getcmdwin_autocmd() | |
1344 | - CheckFeature cmdwin | |
1345 | - | |
1346 | - let s:seq = [] | |
1347 | - augroup CmdWin | |
1348 | - au WinEnter * call add(s:seq, 'WinEnter ' .. win_getid()) | |
1349 | - au WinLeave * call add(s:seq, 'WinLeave ' .. win_getid()) | |
1350 | - au BufEnter * call add(s:seq, 'BufEnter ' .. bufnr()) | |
1351 | - au BufLeave * call add(s:seq, 'BufLeave ' .. bufnr()) | |
1352 | - au CmdWinEnter * call add(s:seq, 'CmdWinEnter ' .. win_getid()) | |
1353 | - au CmdWinLeave * call add(s:seq, 'CmdWinLeave ' .. win_getid()) | |
1354 | - | |
1355 | - let org_winid = win_getid() | |
1356 | - let org_bufnr = bufnr() | |
1357 | - call feedkeys("q::let a = getcmdwintype()\<CR>:let s:cmd_winid = win_getid()\<CR>:let s:cmd_bufnr = bufnr()\<CR>:q\<CR>", 'x!') | |
1358 | - call assert_equal(':', a) | |
1359 | - call assert_equal([ | |
1360 | - \ 'WinLeave ' .. org_winid, | |
1361 | - \ 'WinEnter ' .. s:cmd_winid, | |
1362 | - \ 'BufLeave ' .. org_bufnr, | |
1363 | - \ 'BufEnter ' .. s:cmd_bufnr, | |
1364 | - \ 'CmdWinEnter ' .. s:cmd_winid, | |
1365 | - \ 'CmdWinLeave ' .. s:cmd_winid, | |
1366 | - \ 'BufLeave ' .. s:cmd_bufnr, | |
1367 | - \ 'WinLeave ' .. s:cmd_winid, | |
1368 | - \ 'WinEnter ' .. org_winid, | |
1369 | - \ 'BufEnter ' .. org_bufnr, | |
1370 | - \ ], s:seq) | |
1371 | - | |
1372 | - au! | |
1373 | - augroup END | |
1374 | -endfunc | |
1375 | - | |
1376 | 1325 | func Test_verbosefile() |
1377 | 1326 | set verbosefile=Xlog |
1378 | 1327 | echomsg 'foo' |
@@ -1454,65 +1403,6 @@ | ||
1454 | 1403 | let &encoding = encoding_save |
1455 | 1404 | endfunc |
1456 | 1405 | |
1457 | -func Test_cmdwin_bug() | |
1458 | - CheckFeature cmdwin | |
1459 | - | |
1460 | - let winid = win_getid() | |
1461 | - sp | |
1462 | - try | |
1463 | - call feedkeys("q::call win_gotoid(" .. winid .. ")\<CR>:q\<CR>", 'x!') | |
1464 | - catch /^Vim\%((\a\+)\)\=:E11/ | |
1465 | - endtry | |
1466 | - bw! | |
1467 | -endfunc | |
1468 | - | |
1469 | -func Test_cmdwin_restore() | |
1470 | - CheckFeature cmdwin | |
1471 | - CheckScreendump | |
1472 | - | |
1473 | - let lines =<< trim [SCRIPT] | |
1474 | - augroup vimHints | au! | augroup END | |
1475 | - call setline(1, range(30)) | |
1476 | - 2split | |
1477 | - [SCRIPT] | |
1478 | - call writefile(lines, 'XTest_restore') | |
1479 | - | |
1480 | - let buf = RunVimInTerminal('-S XTest_restore', {'rows': 12}) | |
1481 | - call TermWait(buf, 50) | |
1482 | - call term_sendkeys(buf, "q:") | |
1483 | - call VerifyScreenDump(buf, 'Test_cmdwin_restore_1', {}) | |
1484 | - | |
1485 | - " normal restore | |
1486 | - call term_sendkeys(buf, ":q\<CR>") | |
1487 | - call VerifyScreenDump(buf, 'Test_cmdwin_restore_2', {}) | |
1488 | - | |
1489 | - " restore after setting 'lines' with one window | |
1490 | - call term_sendkeys(buf, ":close\<CR>") | |
1491 | - call term_sendkeys(buf, "q:") | |
1492 | - call term_sendkeys(buf, ":set lines=18\<CR>") | |
1493 | - call term_sendkeys(buf, ":q\<CR>") | |
1494 | - call VerifyScreenDump(buf, 'Test_cmdwin_restore_3', {}) | |
1495 | - | |
1496 | - " clean up | |
1497 | - call StopVimInTerminal(buf) | |
1498 | - call delete('XTest_restore') | |
1499 | -endfunc | |
1500 | - | |
1501 | -func Test_cmdwin_no_terminal() | |
1502 | - CheckFeature cmdwin | |
1503 | - CheckFeature terminal | |
1504 | - CheckNotMSWindows | |
1505 | - | |
1506 | - let buf = RunVimInTerminal('', {'rows': 12}) | |
1507 | - call TermWait(buf, 50) | |
1508 | - call term_sendkeys(buf, ":set cmdheight=2\<CR>") | |
1509 | - call term_sendkeys(buf, "q:") | |
1510 | - call term_sendkeys(buf, ":let buf = term_start(['/bin/echo'], #{hidden: 1})\<CR>") | |
1511 | - call VerifyScreenDump(buf, 'Test_cmdwin_no_terminal', {}) | |
1512 | - call term_sendkeys(buf, ":q\<CR>") | |
1513 | - call StopVimInTerminal(buf) | |
1514 | -endfunc | |
1515 | - | |
1516 | 1406 | func Test_buffers_lastused() |
1517 | 1407 | " check that buffers are sorted by time when wildmode has lastused |
1518 | 1408 | call test_settime(1550020000) " middle |
@@ -1558,61 +1448,6 @@ | ||
1558 | 1448 | bwipeout bufc |
1559 | 1449 | endfunc |
1560 | 1450 | |
1561 | -func Test_cmdwin_feedkeys() | |
1562 | - CheckFeature cmdwin | |
1563 | - | |
1564 | - " This should not generate E488 | |
1565 | - call feedkeys("q:\<CR>", 'x') | |
1566 | - " Using feedkeys with q: only should automatically close the cmd window | |
1567 | - call feedkeys('q:', 'xt') | |
1568 | - call assert_equal(1, winnr('$')) | |
1569 | - call assert_equal('', getcmdwintype()) | |
1570 | -endfunc | |
1571 | - | |
1572 | -" Tests for the issues fixed in 7.4.441. | |
1573 | -" When 'cedit' is set to Ctrl-C, opening the command window hangs Vim | |
1574 | -func Test_cmdwin_cedit() | |
1575 | - CheckFeature cmdwin | |
1576 | - | |
1577 | - exe "set cedit=\<C-c>" | |
1578 | - normal! : | |
1579 | - call assert_equal(1, winnr('$')) | |
1580 | - | |
1581 | - let g:cmd_wintype = '' | |
1582 | - func CmdWinType() | |
1583 | - let g:cmd_wintype = getcmdwintype() | |
1584 | - let g:wintype = win_gettype() | |
1585 | - return '' | |
1586 | - endfunc | |
1587 | - | |
1588 | - call feedkeys("\<C-c>a\<C-R>=CmdWinType()\<CR>\<CR>") | |
1589 | - echo input('') | |
1590 | - call assert_equal('@', g:cmd_wintype) | |
1591 | - call assert_equal('command', g:wintype) | |
1592 | - | |
1593 | - set cedit&vim | |
1594 | - delfunc CmdWinType | |
1595 | -endfunc | |
1596 | - | |
1597 | -" Test for CmdwinEnter autocmd | |
1598 | -func Test_cmdwin_autocmd() | |
1599 | - CheckFeature cmdwin | |
1600 | - | |
1601 | - augroup CmdWin | |
1602 | - au! | |
1603 | - autocmd BufLeave * if &buftype == '' | update | endif | |
1604 | - autocmd CmdwinEnter * startinsert | |
1605 | - augroup END | |
1606 | - | |
1607 | - call assert_fails('call feedkeys("q:xyz\<CR>", "xt")', 'E492:') | |
1608 | - call assert_equal('xyz', @:) | |
1609 | - | |
1610 | - augroup CmdWin | |
1611 | - au! | |
1612 | - augroup END | |
1613 | - augroup! CmdWin | |
1614 | -endfunc | |
1615 | - | |
1616 | 1451 | func Test_cmdlineclear_tabenter() |
1617 | 1452 | CheckScreendump |
1618 | 1453 |
@@ -1649,57 +1484,6 @@ | ||
1649 | 1484 | call delete('Xfile.java') |
1650 | 1485 | endfunc |
1651 | 1486 | |
1652 | -func Test_cmdwin_jump_to_win() | |
1653 | - CheckFeature cmdwin | |
1654 | - | |
1655 | - call assert_fails('call feedkeys("q:\<C-W>\<C-W>\<CR>", "xt")', 'E11:') | |
1656 | - new | |
1657 | - set modified | |
1658 | - call assert_fails('call feedkeys("q/:qall\<CR>", "xt")', ['E37:', 'E162:']) | |
1659 | - close! | |
1660 | - call feedkeys("q/:close\<CR>", "xt") | |
1661 | - call assert_equal(1, winnr('$')) | |
1662 | - call feedkeys("q/:exit\<CR>", "xt") | |
1663 | - call assert_equal(1, winnr('$')) | |
1664 | - | |
1665 | - " opening command window twice should fail | |
1666 | - call assert_beeps('call feedkeys("q:q:\<CR>\<CR>", "xt")') | |
1667 | - call assert_equal(1, winnr('$')) | |
1668 | -endfunc | |
1669 | - | |
1670 | -func Test_cmdwin_tabpage() | |
1671 | - tabedit | |
1672 | - call assert_fails("silent norm q/g :I\<Esc>", 'E11:') | |
1673 | - tabclose! | |
1674 | -endfunc | |
1675 | - | |
1676 | -func Test_cmdwin_interrupted() | |
1677 | - CheckFeature cmdwin | |
1678 | - CheckScreendump | |
1679 | - | |
1680 | - " aborting the :smile output caused the cmdline window to use the current | |
1681 | - " buffer. | |
1682 | - let lines =<< trim [SCRIPT] | |
1683 | - au WinNew * smile | |
1684 | - [SCRIPT] | |
1685 | - call writefile(lines, 'XTest_cmdwin') | |
1686 | - | |
1687 | - let buf = RunVimInTerminal('-S XTest_cmdwin', {'rows': 18}) | |
1688 | - " open cmdwin | |
1689 | - call term_sendkeys(buf, "q:") | |
1690 | - call WaitForAssert({-> assert_match('-- More --', term_getline(buf, 18))}) | |
1691 | - " quit more prompt for :smile command | |
1692 | - call term_sendkeys(buf, "q") | |
1693 | - call WaitForAssert({-> assert_match('^$', term_getline(buf, 18))}) | |
1694 | - " execute a simple command | |
1695 | - call term_sendkeys(buf, "aecho 'done'\<CR>") | |
1696 | - call VerifyScreenDump(buf, 'Test_cmdwin_interrupted', {}) | |
1697 | - | |
1698 | - " clean up | |
1699 | - call StopVimInTerminal(buf) | |
1700 | - call delete('XTest_cmdwin') | |
1701 | -endfunc | |
1702 | - | |
1703 | 1487 | " Test for backtick expression in the command line |
1704 | 1488 | func Test_cmd_backtick() |
1705 | 1489 | %argd |
@@ -2033,14 +1817,6 @@ | ||
2033 | 1817 | %bwipe! |
2034 | 1818 | endfunc |
2035 | 1819 | |
2036 | -" Test for recursively getting multiple command line inputs | |
2037 | -func Test_cmdwin_multi_input() | |
2038 | - CheckFeature cmdwin | |
2039 | - | |
2040 | - call feedkeys(":\<C-R>=input('P: ')\<CR>\"cyan\<CR>\<CR>", 'xt') | |
2041 | - call assert_equal('"cyan', @:) | |
2042 | -endfunc | |
2043 | - | |
2044 | 1820 | " Test for using CTRL-_ in the command line with 'allowrevins' |
2045 | 1821 | func Test_cmdline_revins() |
2046 | 1822 | CheckNotMSWindows |
@@ -2059,58 +1835,6 @@ | ||
2059 | 1835 | call assert_equal('"ゔ', @:) |
2060 | 1836 | endfunc |
2061 | 1837 | |
2062 | -" Test for normal mode commands not supported in the cmd window | |
2063 | -func Test_cmdwin_blocked_commands() | |
2064 | - CheckFeature cmdwin | |
2065 | - | |
2066 | - call assert_fails('call feedkeys("q:\<C-T>\<CR>", "xt")', 'E11:') | |
2067 | - call assert_fails('call feedkeys("q:\<C-]>\<CR>", "xt")', 'E11:') | |
2068 | - call assert_fails('call feedkeys("q:\<C-^>\<CR>", "xt")', 'E11:') | |
2069 | - call assert_fails('call feedkeys("q:Q\<CR>", "xt")', 'E11:') | |
2070 | - call assert_fails('call feedkeys("q:Z\<CR>", "xt")', 'E11:') | |
2071 | - call assert_fails('call feedkeys("q:\<F1>\<CR>", "xt")', 'E11:') | |
2072 | - call assert_fails('call feedkeys("q:\<C-W>s\<CR>", "xt")', 'E11:') | |
2073 | - call assert_fails('call feedkeys("q:\<C-W>v\<CR>", "xt")', 'E11:') | |
2074 | - call assert_fails('call feedkeys("q:\<C-W>^\<CR>", "xt")', 'E11:') | |
2075 | - call assert_fails('call feedkeys("q:\<C-W>n\<CR>", "xt")', 'E11:') | |
2076 | - call assert_fails('call feedkeys("q:\<C-W>z\<CR>", "xt")', 'E11:') | |
2077 | - call assert_fails('call feedkeys("q:\<C-W>o\<CR>", "xt")', 'E11:') | |
2078 | - call assert_fails('call feedkeys("q:\<C-W>w\<CR>", "xt")', 'E11:') | |
2079 | - call assert_fails('call feedkeys("q:\<C-W>j\<CR>", "xt")', 'E11:') | |
2080 | - call assert_fails('call feedkeys("q:\<C-W>k\<CR>", "xt")', 'E11:') | |
2081 | - call assert_fails('call feedkeys("q:\<C-W>h\<CR>", "xt")', 'E11:') | |
2082 | - call assert_fails('call feedkeys("q:\<C-W>l\<CR>", "xt")', 'E11:') | |
2083 | - call assert_fails('call feedkeys("q:\<C-W>T\<CR>", "xt")', 'E11:') | |
2084 | - call assert_fails('call feedkeys("q:\<C-W>x\<CR>", "xt")', 'E11:') | |
2085 | - call assert_fails('call feedkeys("q:\<C-W>r\<CR>", "xt")', 'E11:') | |
2086 | - call assert_fails('call feedkeys("q:\<C-W>R\<CR>", "xt")', 'E11:') | |
2087 | - call assert_fails('call feedkeys("q:\<C-W>K\<CR>", "xt")', 'E11:') | |
2088 | - call assert_fails('call feedkeys("q:\<C-W>}\<CR>", "xt")', 'E11:') | |
2089 | - call assert_fails('call feedkeys("q:\<C-W>]\<CR>", "xt")', 'E11:') | |
2090 | - call assert_fails('call feedkeys("q:\<C-W>f\<CR>", "xt")', 'E11:') | |
2091 | - call assert_fails('call feedkeys("q:\<C-W>d\<CR>", "xt")', 'E11:') | |
2092 | - call assert_fails('call feedkeys("q:\<C-W>g\<CR>", "xt")', 'E11:') | |
2093 | -endfunc | |
2094 | - | |
2095 | -" Close the Cmd-line window in insert mode using CTRL-C | |
2096 | -func Test_cmdwin_insert_mode_close() | |
2097 | - CheckFeature cmdwin | |
2098 | - | |
2099 | - %bw! | |
2100 | - let s = '' | |
2101 | - exe "normal q:a\<C-C>let s='Hello'\<CR>" | |
2102 | - call assert_equal('Hello', s) | |
2103 | - call assert_equal(1, winnr('$')) | |
2104 | -endfunc | |
2105 | - | |
2106 | -func Test_cmdwin_ex_mode_with_modifier() | |
2107 | - " this was accessing memory after allocated text in Ex mode | |
2108 | - new | |
2109 | - call setline(1, ['some', 'text', 'lines']) | |
2110 | - silent! call feedkeys("gQnormal vq:atopleft\<C-V>\<CR>\<CR>", 'xt') | |
2111 | - bwipe! | |
2112 | -endfunc | |
2113 | - | |
2114 | 1838 | " test that ";" works to find a match at the start of the first line |
2115 | 1839 | func Test_zero_line_search() |
2116 | 1840 | new |
@@ -0,0 +1,360 @@ | ||
1 | +" Tests for editing the command line. | |
2 | + | |
3 | +source check.vim | |
4 | +CheckFeature cmdwin | |
5 | + | |
6 | +source screendump.vim | |
7 | + | |
8 | +func Test_getcmdwintype() | |
9 | + call feedkeys("q/:let a = getcmdwintype()\<CR>:q\<CR>", 'x!') | |
10 | + call assert_equal('/', a) | |
11 | + | |
12 | + call feedkeys("q?:let a = getcmdwintype()\<CR>:q\<CR>", 'x!') | |
13 | + call assert_equal('?', a) | |
14 | + | |
15 | + call feedkeys("q::let a = getcmdwintype()\<CR>:q\<CR>", 'x!') | |
16 | + call assert_equal(':', a) | |
17 | + | |
18 | + call feedkeys(":\<C-F>:let a = getcmdwintype()\<CR>:q\<CR>", 'x!') | |
19 | + call assert_equal(':', a) | |
20 | + | |
21 | + call assert_equal('', getcmdwintype()) | |
22 | +endfunc | |
23 | + | |
24 | +func Test_getcmdwin_autocmd() | |
25 | + let s:seq = [] | |
26 | + augroup CmdWin | |
27 | + au WinEnter * call add(s:seq, 'WinEnter ' .. win_getid()) | |
28 | + au WinLeave * call add(s:seq, 'WinLeave ' .. win_getid()) | |
29 | + au BufEnter * call add(s:seq, 'BufEnter ' .. bufnr()) | |
30 | + au BufLeave * call add(s:seq, 'BufLeave ' .. bufnr()) | |
31 | + au CmdWinEnter * call add(s:seq, 'CmdWinEnter ' .. win_getid()) | |
32 | + au CmdWinLeave * call add(s:seq, 'CmdWinLeave ' .. win_getid()) | |
33 | + | |
34 | + let org_winid = win_getid() | |
35 | + let org_bufnr = bufnr() | |
36 | + call feedkeys("q::let a = getcmdwintype()\<CR>:let s:cmd_winid = win_getid()\<CR>:let s:cmd_bufnr = bufnr()\<CR>:q\<CR>", 'x!') | |
37 | + call assert_equal(':', a) | |
38 | + call assert_equal([ | |
39 | + \ 'WinLeave ' .. org_winid, | |
40 | + \ 'WinEnter ' .. s:cmd_winid, | |
41 | + \ 'BufLeave ' .. org_bufnr, | |
42 | + \ 'BufEnter ' .. s:cmd_bufnr, | |
43 | + \ 'CmdWinEnter ' .. s:cmd_winid, | |
44 | + \ 'CmdWinLeave ' .. s:cmd_winid, | |
45 | + \ 'BufLeave ' .. s:cmd_bufnr, | |
46 | + \ 'WinLeave ' .. s:cmd_winid, | |
47 | + \ 'WinEnter ' .. org_winid, | |
48 | + \ 'BufEnter ' .. org_bufnr, | |
49 | + \ ], s:seq) | |
50 | + | |
51 | + au! | |
52 | + augroup END | |
53 | +endfunc | |
54 | + | |
55 | +func Test_cmdwin_bug() | |
56 | + let winid = win_getid() | |
57 | + sp | |
58 | + try | |
59 | + call feedkeys("q::call win_gotoid(" .. winid .. ")\<CR>:q\<CR>", 'x!') | |
60 | + catch /^Vim\%((\a\+)\)\=:E11/ | |
61 | + endtry | |
62 | + bw! | |
63 | +endfunc | |
64 | + | |
65 | +func Test_cmdwin_restore() | |
66 | + CheckScreendump | |
67 | + | |
68 | + let lines =<< trim [SCRIPT] | |
69 | + augroup vimHints | au! | augroup END | |
70 | + call setline(1, range(30)) | |
71 | + 2split | |
72 | + [SCRIPT] | |
73 | + call writefile(lines, 'XTest_restore') | |
74 | + | |
75 | + let buf = RunVimInTerminal('-S XTest_restore', {'rows': 12}) | |
76 | + call TermWait(buf, 50) | |
77 | + call term_sendkeys(buf, "q:") | |
78 | + call VerifyScreenDump(buf, 'Test_cmdwin_restore_1', {}) | |
79 | + | |
80 | + " normal restore | |
81 | + call term_sendkeys(buf, ":q\<CR>") | |
82 | + call VerifyScreenDump(buf, 'Test_cmdwin_restore_2', {}) | |
83 | + | |
84 | + " restore after setting 'lines' with one window | |
85 | + call term_sendkeys(buf, ":close\<CR>") | |
86 | + call term_sendkeys(buf, "q:") | |
87 | + call term_sendkeys(buf, ":set lines=18\<CR>") | |
88 | + call term_sendkeys(buf, ":q\<CR>") | |
89 | + call VerifyScreenDump(buf, 'Test_cmdwin_restore_3', {}) | |
90 | + | |
91 | + " clean up | |
92 | + call StopVimInTerminal(buf) | |
93 | + call delete('XTest_restore') | |
94 | +endfunc | |
95 | + | |
96 | +func Test_cmdwin_no_terminal() | |
97 | + CheckFeature terminal | |
98 | + CheckNotMSWindows | |
99 | + | |
100 | + let buf = RunVimInTerminal('', {'rows': 12}) | |
101 | + call TermWait(buf, 50) | |
102 | + call term_sendkeys(buf, ":set cmdheight=2\<CR>") | |
103 | + call term_sendkeys(buf, "q:") | |
104 | + call term_sendkeys(buf, ":let buf = term_start(['/bin/echo'], #{hidden: 1})\<CR>") | |
105 | + call VerifyScreenDump(buf, 'Test_cmdwin_no_terminal', {}) | |
106 | + call term_sendkeys(buf, ":q\<CR>") | |
107 | + call StopVimInTerminal(buf) | |
108 | +endfunc | |
109 | + | |
110 | +func Test_cmdwin_feedkeys() | |
111 | + " This should not generate E488 | |
112 | + call feedkeys("q:\<CR>", 'x') | |
113 | + " Using feedkeys with q: only should automatically close the cmd window | |
114 | + call feedkeys('q:', 'xt') | |
115 | + call assert_equal(1, winnr('$')) | |
116 | + call assert_equal('', getcmdwintype()) | |
117 | +endfunc | |
118 | + | |
119 | +" Tests for the issues fixed in 7.4.441. | |
120 | +" When 'cedit' is set to Ctrl-C, opening the command window hangs Vim | |
121 | +func Test_cmdwin_cedit() | |
122 | + exe "set cedit=\<C-c>" | |
123 | + normal! : | |
124 | + call assert_equal(1, winnr('$')) | |
125 | + | |
126 | + let g:cmd_wintype = '' | |
127 | + func CmdWinType() | |
128 | + let g:cmd_wintype = getcmdwintype() | |
129 | + let g:wintype = win_gettype() | |
130 | + return '' | |
131 | + endfunc | |
132 | + | |
133 | + call feedkeys("\<C-c>a\<C-R>=CmdWinType()\<CR>\<CR>") | |
134 | + echo input('') | |
135 | + call assert_equal('@', g:cmd_wintype) | |
136 | + call assert_equal('command', g:wintype) | |
137 | + | |
138 | + set cedit&vim | |
139 | + delfunc CmdWinType | |
140 | +endfunc | |
141 | + | |
142 | +" Test for CmdwinEnter autocmd | |
143 | +func Test_cmdwin_autocmd() | |
144 | + augroup CmdWin | |
145 | + au! | |
146 | + autocmd BufLeave * if &buftype == '' | update | endif | |
147 | + autocmd CmdwinEnter * startinsert | |
148 | + augroup END | |
149 | + | |
150 | + call assert_fails('call feedkeys("q:xyz\<CR>", "xt")', 'E492:') | |
151 | + call assert_equal('xyz', @:) | |
152 | + | |
153 | + augroup CmdWin | |
154 | + au! | |
155 | + augroup END | |
156 | + augroup! CmdWin | |
157 | +endfunc | |
158 | + | |
159 | +func Test_cmdwin_jump_to_win() | |
160 | + call assert_fails('call feedkeys("q:\<C-W>\<C-W>\<CR>", "xt")', 'E11:') | |
161 | + new | |
162 | + set modified | |
163 | + call assert_fails('call feedkeys("q/:qall\<CR>", "xt")', ['E37:', 'E162:']) | |
164 | + close! | |
165 | + call feedkeys("q/:close\<CR>", "xt") | |
166 | + call assert_equal(1, winnr('$')) | |
167 | + call feedkeys("q/:exit\<CR>", "xt") | |
168 | + call assert_equal(1, winnr('$')) | |
169 | + | |
170 | + " opening command window twice should fail | |
171 | + call assert_beeps('call feedkeys("q:q:\<CR>\<CR>", "xt")') | |
172 | + call assert_equal(1, winnr('$')) | |
173 | +endfunc | |
174 | + | |
175 | +func Test_cmdwin_tabpage() | |
176 | + tabedit | |
177 | + call assert_fails("silent norm q/g :I\<Esc>", 'E11:') | |
178 | + tabclose! | |
179 | +endfunc | |
180 | + | |
181 | +func Test_cmdwin_interrupted() | |
182 | + CheckScreendump | |
183 | + | |
184 | + " aborting the :smile output caused the cmdline window to use the current | |
185 | + " buffer. | |
186 | + let lines =<< trim [SCRIPT] | |
187 | + au WinNew * smile | |
188 | + [SCRIPT] | |
189 | + call writefile(lines, 'XTest_cmdwin') | |
190 | + | |
191 | + let buf = RunVimInTerminal('-S XTest_cmdwin', {'rows': 18}) | |
192 | + " open cmdwin | |
193 | + call term_sendkeys(buf, "q:") | |
194 | + call WaitForAssert({-> assert_match('-- More --', term_getline(buf, 18))}) | |
195 | + " quit more prompt for :smile command | |
196 | + call term_sendkeys(buf, "q") | |
197 | + call WaitForAssert({-> assert_match('^$', term_getline(buf, 18))}) | |
198 | + " execute a simple command | |
199 | + call term_sendkeys(buf, "aecho 'done'\<CR>") | |
200 | + call VerifyScreenDump(buf, 'Test_cmdwin_interrupted', {}) | |
201 | + | |
202 | + " clean up | |
203 | + call StopVimInTerminal(buf) | |
204 | + call delete('XTest_cmdwin') | |
205 | +endfunc | |
206 | + | |
207 | +" Test for recursively getting multiple command line inputs | |
208 | +func Test_cmdwin_multi_input() | |
209 | + call feedkeys(":\<C-R>=input('P: ')\<CR>\"cyan\<CR>\<CR>", 'xt') | |
210 | + call assert_equal('"cyan', @:) | |
211 | +endfunc | |
212 | + | |
213 | +" Test for normal mode commands not supported in the cmd window | |
214 | +func Test_cmdwin_blocked_commands() | |
215 | + call assert_fails('call feedkeys("q:\<C-T>\<CR>", "xt")', 'E11:') | |
216 | + call assert_fails('call feedkeys("q:\<C-]>\<CR>", "xt")', 'E11:') | |
217 | + call assert_fails('call feedkeys("q:\<C-^>\<CR>", "xt")', 'E11:') | |
218 | + call assert_fails('call feedkeys("q:Q\<CR>", "xt")', 'E11:') | |
219 | + call assert_fails('call feedkeys("q:Z\<CR>", "xt")', 'E11:') | |
220 | + call assert_fails('call feedkeys("q:\<F1>\<CR>", "xt")', 'E11:') | |
221 | + call assert_fails('call feedkeys("q:\<C-W>s\<CR>", "xt")', 'E11:') | |
222 | + call assert_fails('call feedkeys("q:\<C-W>v\<CR>", "xt")', 'E11:') | |
223 | + call assert_fails('call feedkeys("q:\<C-W>^\<CR>", "xt")', 'E11:') | |
224 | + call assert_fails('call feedkeys("q:\<C-W>n\<CR>", "xt")', 'E11:') | |
225 | + call assert_fails('call feedkeys("q:\<C-W>z\<CR>", "xt")', 'E11:') | |
226 | + call assert_fails('call feedkeys("q:\<C-W>o\<CR>", "xt")', 'E11:') | |
227 | + call assert_fails('call feedkeys("q:\<C-W>w\<CR>", "xt")', 'E11:') | |
228 | + call assert_fails('call feedkeys("q:\<C-W>j\<CR>", "xt")', 'E11:') | |
229 | + call assert_fails('call feedkeys("q:\<C-W>k\<CR>", "xt")', 'E11:') | |
230 | + call assert_fails('call feedkeys("q:\<C-W>h\<CR>", "xt")', 'E11:') | |
231 | + call assert_fails('call feedkeys("q:\<C-W>l\<CR>", "xt")', 'E11:') | |
232 | + call assert_fails('call feedkeys("q:\<C-W>T\<CR>", "xt")', 'E11:') | |
233 | + call assert_fails('call feedkeys("q:\<C-W>x\<CR>", "xt")', 'E11:') | |
234 | + call assert_fails('call feedkeys("q:\<C-W>r\<CR>", "xt")', 'E11:') | |
235 | + call assert_fails('call feedkeys("q:\<C-W>R\<CR>", "xt")', 'E11:') | |
236 | + call assert_fails('call feedkeys("q:\<C-W>K\<CR>", "xt")', 'E11:') | |
237 | + call assert_fails('call feedkeys("q:\<C-W>}\<CR>", "xt")', 'E11:') | |
238 | + call assert_fails('call feedkeys("q:\<C-W>]\<CR>", "xt")', 'E11:') | |
239 | + call assert_fails('call feedkeys("q:\<C-W>f\<CR>", "xt")', 'E11:') | |
240 | + call assert_fails('call feedkeys("q:\<C-W>d\<CR>", "xt")', 'E11:') | |
241 | + call assert_fails('call feedkeys("q:\<C-W>g\<CR>", "xt")', 'E11:') | |
242 | +endfunc | |
243 | + | |
244 | +" Close the Cmd-line window in insert mode using CTRL-C | |
245 | +func Test_cmdwin_insert_mode_close() | |
246 | + %bw! | |
247 | + let s = '' | |
248 | + exe "normal q:a\<C-C>let s='Hello'\<CR>" | |
249 | + call assert_equal('Hello', s) | |
250 | + call assert_equal(1, winnr('$')) | |
251 | +endfunc | |
252 | + | |
253 | +func Test_cmdwin_ex_mode_with_modifier() | |
254 | + " this was accessing memory after allocated text in Ex mode | |
255 | + new | |
256 | + call setline(1, ['some', 'text', 'lines']) | |
257 | + silent! call feedkeys("gQnormal vq:atopleft\<C-V>\<CR>\<CR>", 'xt') | |
258 | + bwipe! | |
259 | +endfunc | |
260 | + | |
261 | +func s:ComplInCmdwin_GlobalCompletion(a, l, p) | |
262 | + return 'global' | |
263 | +endfunc | |
264 | + | |
265 | +func s:ComplInCmdwin_LocalCompletion(a, l, p) | |
266 | + return 'local' | |
267 | +endfunc | |
268 | + | |
269 | +func Test_compl_in_cmdwin() | |
270 | + set wildmenu wildchar=<Tab> | |
271 | + com! -nargs=1 -complete=command GetInput let input = <q-args> | |
272 | + com! -buffer TestCommand echo 'TestCommand' | |
273 | + let w:test_winvar = 'winvar' | |
274 | + let b:test_bufvar = 'bufvar' | |
275 | + | |
276 | + " User-defined commands | |
277 | + let input = '' | |
278 | + call feedkeys("q:iGetInput T\<C-x>\<C-v>\<CR>", 'tx!') | |
279 | + call assert_equal('TestCommand', input) | |
280 | + | |
281 | + let input = '' | |
282 | + call feedkeys("q::GetInput T\<Tab>\<CR>:q\<CR>", 'tx!') | |
283 | + call assert_equal('T', input) | |
284 | + | |
285 | + | |
286 | + com! -nargs=1 -complete=var GetInput let input = <q-args> | |
287 | + " Window-local variables | |
288 | + let input = '' | |
289 | + call feedkeys("q:iGetInput w:test_\<C-x>\<C-v>\<CR>", 'tx!') | |
290 | + call assert_equal('w:test_winvar', input) | |
291 | + | |
292 | + let input = '' | |
293 | + call feedkeys("q::GetInput w:test_\<Tab>\<CR>:q\<CR>", 'tx!') | |
294 | + call assert_equal('w:test_', input) | |
295 | + | |
296 | + " Buffer-local variables | |
297 | + let input = '' | |
298 | + call feedkeys("q:iGetInput b:test_\<C-x>\<C-v>\<CR>", 'tx!') | |
299 | + call assert_equal('b:test_bufvar', input) | |
300 | + | |
301 | + let input = '' | |
302 | + call feedkeys("q::GetInput b:test_\<Tab>\<CR>:q\<CR>", 'tx!') | |
303 | + call assert_equal('b:test_', input) | |
304 | + | |
305 | + | |
306 | + " Argument completion of buffer-local command | |
307 | + func s:ComplInCmdwin_GlobalCompletionList(a, l, p) | |
308 | + return ['global'] | |
309 | + endfunc | |
310 | + | |
311 | + func s:ComplInCmdwin_LocalCompletionList(a, l, p) | |
312 | + return ['local'] | |
313 | + endfunc | |
314 | + | |
315 | + func s:ComplInCmdwin_CheckCompletion(arg) | |
316 | + call assert_equal('local', a:arg) | |
317 | + endfunc | |
318 | + | |
319 | + com! -nargs=1 -complete=custom,<SID>ComplInCmdwin_GlobalCompletion | |
320 | + \ TestCommand call s:ComplInCmdwin_CheckCompletion(<q-args>) | |
321 | + com! -buffer -nargs=1 -complete=custom,<SID>ComplInCmdwin_LocalCompletion | |
322 | + \ TestCommand call s:ComplInCmdwin_CheckCompletion(<q-args>) | |
323 | + call feedkeys("q:iTestCommand \<Tab>\<CR>", 'tx!') | |
324 | + | |
325 | + com! -nargs=1 -complete=customlist,<SID>ComplInCmdwin_GlobalCompletionList | |
326 | + \ TestCommand call s:ComplInCmdwin_CheckCompletion(<q-args>) | |
327 | + com! -buffer -nargs=1 -complete=customlist,<SID>ComplInCmdwin_LocalCompletionList | |
328 | + \ TestCommand call s:ComplInCmdwin_CheckCompletion(<q-args>) | |
329 | + | |
330 | + call feedkeys("q:iTestCommand \<Tab>\<CR>", 'tx!') | |
331 | + | |
332 | + func! s:ComplInCmdwin_CheckCompletion(arg) | |
333 | + call assert_equal('global', a:arg) | |
334 | + endfunc | |
335 | + new | |
336 | + call feedkeys("q:iTestCommand \<Tab>\<CR>", 'tx!') | |
337 | + quit | |
338 | + | |
339 | + delfunc s:ComplInCmdwin_GlobalCompletion | |
340 | + delfunc s:ComplInCmdwin_LocalCompletion | |
341 | + delfunc s:ComplInCmdwin_GlobalCompletionList | |
342 | + delfunc s:ComplInCmdwin_LocalCompletionList | |
343 | + delfunc s:ComplInCmdwin_CheckCompletion | |
344 | + | |
345 | + delcom -buffer TestCommand | |
346 | + delcom TestCommand | |
347 | + delcom GetInput | |
348 | + unlet w:test_winvar | |
349 | + unlet b:test_bufvar | |
350 | + set wildmenu& wildchar& | |
351 | +endfunc | |
352 | + | |
353 | +func Test_cmdwin_ctrl_bsl() | |
354 | + " Using CTRL-\ CTRL-N in cmd window should close the window | |
355 | + call feedkeys("q:\<C-\>\<C-N>", 'xt') | |
356 | + call assert_equal('', getcmdwintype()) | |
357 | +endfunc | |
358 | + | |
359 | + | |
360 | +" vim: shiftwidth=2 sts=2 expandtab |
@@ -416,100 +416,6 @@ | ||
416 | 416 | set completeopt& |
417 | 417 | endfunc |
418 | 418 | |
419 | -func s:ComplInCmdwin_GlobalCompletion(a, l, p) | |
420 | - return 'global' | |
421 | -endfunc | |
422 | - | |
423 | -func s:ComplInCmdwin_LocalCompletion(a, l, p) | |
424 | - return 'local' | |
425 | -endfunc | |
426 | - | |
427 | -func Test_compl_in_cmdwin() | |
428 | - CheckFeature cmdwin | |
429 | - | |
430 | - set wildmenu wildchar=<Tab> | |
431 | - com! -nargs=1 -complete=command GetInput let input = <q-args> | |
432 | - com! -buffer TestCommand echo 'TestCommand' | |
433 | - let w:test_winvar = 'winvar' | |
434 | - let b:test_bufvar = 'bufvar' | |
435 | - | |
436 | - " User-defined commands | |
437 | - let input = '' | |
438 | - call feedkeys("q:iGetInput T\<C-x>\<C-v>\<CR>", 'tx!') | |
439 | - call assert_equal('TestCommand', input) | |
440 | - | |
441 | - let input = '' | |
442 | - call feedkeys("q::GetInput T\<Tab>\<CR>:q\<CR>", 'tx!') | |
443 | - call assert_equal('T', input) | |
444 | - | |
445 | - | |
446 | - com! -nargs=1 -complete=var GetInput let input = <q-args> | |
447 | - " Window-local variables | |
448 | - let input = '' | |
449 | - call feedkeys("q:iGetInput w:test_\<C-x>\<C-v>\<CR>", 'tx!') | |
450 | - call assert_equal('w:test_winvar', input) | |
451 | - | |
452 | - let input = '' | |
453 | - call feedkeys("q::GetInput w:test_\<Tab>\<CR>:q\<CR>", 'tx!') | |
454 | - call assert_equal('w:test_', input) | |
455 | - | |
456 | - " Buffer-local variables | |
457 | - let input = '' | |
458 | - call feedkeys("q:iGetInput b:test_\<C-x>\<C-v>\<CR>", 'tx!') | |
459 | - call assert_equal('b:test_bufvar', input) | |
460 | - | |
461 | - let input = '' | |
462 | - call feedkeys("q::GetInput b:test_\<Tab>\<CR>:q\<CR>", 'tx!') | |
463 | - call assert_equal('b:test_', input) | |
464 | - | |
465 | - | |
466 | - " Argument completion of buffer-local command | |
467 | - func s:ComplInCmdwin_GlobalCompletionList(a, l, p) | |
468 | - return ['global'] | |
469 | - endfunc | |
470 | - | |
471 | - func s:ComplInCmdwin_LocalCompletionList(a, l, p) | |
472 | - return ['local'] | |
473 | - endfunc | |
474 | - | |
475 | - func s:ComplInCmdwin_CheckCompletion(arg) | |
476 | - call assert_equal('local', a:arg) | |
477 | - endfunc | |
478 | - | |
479 | - com! -nargs=1 -complete=custom,<SID>ComplInCmdwin_GlobalCompletion | |
480 | - \ TestCommand call s:ComplInCmdwin_CheckCompletion(<q-args>) | |
481 | - com! -buffer -nargs=1 -complete=custom,<SID>ComplInCmdwin_LocalCompletion | |
482 | - \ TestCommand call s:ComplInCmdwin_CheckCompletion(<q-args>) | |
483 | - call feedkeys("q:iTestCommand \<Tab>\<CR>", 'tx!') | |
484 | - | |
485 | - com! -nargs=1 -complete=customlist,<SID>ComplInCmdwin_GlobalCompletionList | |
486 | - \ TestCommand call s:ComplInCmdwin_CheckCompletion(<q-args>) | |
487 | - com! -buffer -nargs=1 -complete=customlist,<SID>ComplInCmdwin_LocalCompletionList | |
488 | - \ TestCommand call s:ComplInCmdwin_CheckCompletion(<q-args>) | |
489 | - | |
490 | - call feedkeys("q:iTestCommand \<Tab>\<CR>", 'tx!') | |
491 | - | |
492 | - func! s:ComplInCmdwin_CheckCompletion(arg) | |
493 | - call assert_equal('global', a:arg) | |
494 | - endfunc | |
495 | - new | |
496 | - call feedkeys("q:iTestCommand \<Tab>\<CR>", 'tx!') | |
497 | - quit | |
498 | - | |
499 | - delfunc s:ComplInCmdwin_GlobalCompletion | |
500 | - delfunc s:ComplInCmdwin_LocalCompletion | |
501 | - delfunc s:ComplInCmdwin_GlobalCompletionList | |
502 | - delfunc s:ComplInCmdwin_LocalCompletionList | |
503 | - delfunc s:ComplInCmdwin_CheckCompletion | |
504 | - | |
505 | - delcom -buffer TestCommand | |
506 | - delcom TestCommand | |
507 | - delcom GetInput | |
508 | - unlet w:test_winvar | |
509 | - unlet b:test_bufvar | |
510 | - set wildmenu& wildchar& | |
511 | -endfunc | |
512 | - | |
513 | 419 | " Test for insert path completion with completeslash option |
514 | 420 | func Test_ins_completeslash() |
515 | 421 | CheckMSWindows |
@@ -2191,5 +2097,4 @@ | ||
2191 | 2097 | bwipe! |
2192 | 2098 | endfunc |
2193 | 2099 | |
2194 | - | |
2195 | 2100 | " vim: shiftwidth=2 sts=2 expandtab |
@@ -2945,12 +2945,6 @@ | ||
2945 | 2945 | call assert_false(&insertmode) |
2946 | 2946 | call assert_beeps("normal! \<C-\>\<C-A>") |
2947 | 2947 | |
2948 | - if has('cmdwin') | |
2949 | - " Using CTRL-\ CTRL-N in cmd window should close the window | |
2950 | - call feedkeys("q:\<C-\>\<C-N>", 'xt') | |
2951 | - call assert_equal('', getcmdwintype()) | |
2952 | - endif | |
2953 | - | |
2954 | 2948 | " clean up |
2955 | 2949 | bw! |
2956 | 2950 | endfunc |
@@ -736,6 +736,8 @@ | ||
736 | 736 | static int included_patches[] = |
737 | 737 | { /* Add new patch number below this line */ |
738 | 738 | /**/ |
739 | + 27, | |
740 | +/**/ | |
739 | 741 | 26, |
740 | 742 | /**/ |
741 | 743 | 25, |