annotate src/testdir/test_cmdwin.vim @ 29444:44bb4a607125 v9.0.0064

patch 9.0.0064: confusing error when using "q:" in command line window Commit: https://github.com/vim/vim/commit/c963ec31a0c293d629e40cb082d4bfb1651def49 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 24 20:08:01 2022 +0100 patch 9.0.0064: confusing error when using "q:" in command line window Problem: Confusing error when using "q:" in command line window. Solution: Check for the situation and give a better error message. (closes #10756)
author Bram Moolenaar <Bram@vim.org>
date Sun, 24 Jul 2022 21:15:06 +0200
parents b1f345ec827e
children beab53bb989e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29369
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 " Tests for editing the command line.
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3 source check.vim
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4 CheckFeature cmdwin
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 source screendump.vim
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 func Test_getcmdwintype()
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 call feedkeys("q/:let a = getcmdwintype()\<CR>:q\<CR>", 'x!')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 call assert_equal('/', a)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 call feedkeys("q?:let a = getcmdwintype()\<CR>:q\<CR>", 'x!')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13 call assert_equal('?', a)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15 call feedkeys("q::let a = getcmdwintype()\<CR>:q\<CR>", 'x!')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 call assert_equal(':', a)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 call feedkeys(":\<C-F>:let a = getcmdwintype()\<CR>:q\<CR>", 'x!')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 call assert_equal(':', a)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 call assert_equal('', getcmdwintype())
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 endfunc
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 func Test_getcmdwin_autocmd()
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25 let s:seq = []
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 augroup CmdWin
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 au WinEnter * call add(s:seq, 'WinEnter ' .. win_getid())
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 au WinLeave * call add(s:seq, 'WinLeave ' .. win_getid())
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 au BufEnter * call add(s:seq, 'BufEnter ' .. bufnr())
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 au BufLeave * call add(s:seq, 'BufLeave ' .. bufnr())
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 au CmdWinEnter * call add(s:seq, 'CmdWinEnter ' .. win_getid())
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 au CmdWinLeave * call add(s:seq, 'CmdWinLeave ' .. win_getid())
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 let org_winid = win_getid()
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 let org_bufnr = bufnr()
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 call feedkeys("q::let a = getcmdwintype()\<CR>:let s:cmd_winid = win_getid()\<CR>:let s:cmd_bufnr = bufnr()\<CR>:q\<CR>", 'x!')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 call assert_equal(':', a)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 call assert_equal([
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 \ 'WinLeave ' .. org_winid,
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 \ 'WinEnter ' .. s:cmd_winid,
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 \ 'BufLeave ' .. org_bufnr,
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 \ 'BufEnter ' .. s:cmd_bufnr,
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 \ 'CmdWinEnter ' .. s:cmd_winid,
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 \ 'CmdWinLeave ' .. s:cmd_winid,
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 \ 'BufLeave ' .. s:cmd_bufnr,
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 \ 'WinLeave ' .. s:cmd_winid,
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 \ 'WinEnter ' .. org_winid,
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 \ 'BufEnter ' .. org_bufnr,
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 \ ], s:seq)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 au!
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 augroup END
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 endfunc
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 func Test_cmdwin_bug()
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 let winid = win_getid()
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 sp
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 try
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59 call feedkeys("q::call win_gotoid(" .. winid .. ")\<CR>:q\<CR>", 'x!')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 catch /^Vim\%((\a\+)\)\=:E11/
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 endtry
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 bw!
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 endfunc
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 func Test_cmdwin_restore()
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66 CheckScreendump
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 let lines =<< trim [SCRIPT]
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69 augroup vimHints | au! | augroup END
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 call setline(1, range(30))
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71 2split
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72 [SCRIPT]
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 call writefile(lines, 'XTest_restore')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 let buf = RunVimInTerminal('-S XTest_restore', {'rows': 12})
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 call TermWait(buf, 50)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77 call term_sendkeys(buf, "q:")
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 call VerifyScreenDump(buf, 'Test_cmdwin_restore_1', {})
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 " normal restore
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 call term_sendkeys(buf, ":q\<CR>")
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82 call VerifyScreenDump(buf, 'Test_cmdwin_restore_2', {})
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 " restore after setting 'lines' with one window
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 call term_sendkeys(buf, ":close\<CR>")
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86 call term_sendkeys(buf, "q:")
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87 call term_sendkeys(buf, ":set lines=18\<CR>")
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88 call term_sendkeys(buf, ":q\<CR>")
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 call VerifyScreenDump(buf, 'Test_cmdwin_restore_3', {})
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 " clean up
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 call StopVimInTerminal(buf)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93 call delete('XTest_restore')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 endfunc
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 func Test_cmdwin_no_terminal()
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 CheckFeature terminal
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98 CheckNotMSWindows
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100 let buf = RunVimInTerminal('', {'rows': 12})
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 call TermWait(buf, 50)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102 call term_sendkeys(buf, ":set cmdheight=2\<CR>")
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
103 call term_sendkeys(buf, "q:")
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
104 call term_sendkeys(buf, ":let buf = term_start(['/bin/echo'], #{hidden: 1})\<CR>")
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105 call VerifyScreenDump(buf, 'Test_cmdwin_no_terminal', {})
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
106 call term_sendkeys(buf, ":q\<CR>")
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107 call StopVimInTerminal(buf)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108 endfunc
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
110 func Test_cmdwin_feedkeys()
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
111 " This should not generate E488
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112 call feedkeys("q:\<CR>", 'x')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113 " Using feedkeys with q: only should automatically close the cmd window
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
114 call feedkeys('q:', 'xt')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
115 call assert_equal(1, winnr('$'))
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116 call assert_equal('', getcmdwintype())
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
117 endfunc
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119 " Tests for the issues fixed in 7.4.441.
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
120 " When 'cedit' is set to Ctrl-C, opening the command window hangs Vim
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
121 func Test_cmdwin_cedit()
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
122 exe "set cedit=\<C-c>"
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
123 normal! :
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
124 call assert_equal(1, winnr('$'))
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
125
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
126 let g:cmd_wintype = ''
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
127 func CmdWinType()
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
128 let g:cmd_wintype = getcmdwintype()
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
129 let g:wintype = win_gettype()
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
130 return ''
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
131 endfunc
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
132
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
133 call feedkeys("\<C-c>a\<C-R>=CmdWinType()\<CR>\<CR>")
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
134 echo input('')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
135 call assert_equal('@', g:cmd_wintype)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
136 call assert_equal('command', g:wintype)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
137
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
138 set cedit&vim
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
139 delfunc CmdWinType
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
140 endfunc
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
141
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
142 " Test for CmdwinEnter autocmd
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
143 func Test_cmdwin_autocmd()
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
144 augroup CmdWin
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
145 au!
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
146 autocmd BufLeave * if &buftype == '' | update | endif
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
147 autocmd CmdwinEnter * startinsert
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
148 augroup END
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
149
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
150 call assert_fails('call feedkeys("q:xyz\<CR>", "xt")', 'E492:')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
151 call assert_equal('xyz', @:)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
152
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
153 augroup CmdWin
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
154 au!
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
155 augroup END
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
156 augroup! CmdWin
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
157 endfunc
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
158
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
159 func Test_cmdwin_jump_to_win()
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
160 call assert_fails('call feedkeys("q:\<C-W>\<C-W>\<CR>", "xt")', 'E11:')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
161 new
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
162 set modified
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
163 call assert_fails('call feedkeys("q/:qall\<CR>", "xt")', ['E37:', 'E162:'])
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
164 close!
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
165 call feedkeys("q/:close\<CR>", "xt")
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
166 call assert_equal(1, winnr('$'))
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
167 call feedkeys("q/:exit\<CR>", "xt")
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
168 call assert_equal(1, winnr('$'))
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
169
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
170 " opening command window twice should fail
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
171 call assert_beeps('call feedkeys("q:q:\<CR>\<CR>", "xt")')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
172 call assert_equal(1, winnr('$'))
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
173 endfunc
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
174
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
175 func Test_cmdwin_tabpage()
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
176 tabedit
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
177 call assert_fails("silent norm q/g :I\<Esc>", 'E11:')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
178 tabclose!
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
179 endfunc
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
180
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
181 func Test_cmdwin_interrupted()
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
182 CheckScreendump
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
183
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
184 " aborting the :smile output caused the cmdline window to use the current
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
185 " buffer.
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
186 let lines =<< trim [SCRIPT]
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
187 au WinNew * smile
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
188 [SCRIPT]
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
189 call writefile(lines, 'XTest_cmdwin')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
190
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
191 let buf = RunVimInTerminal('-S XTest_cmdwin', {'rows': 18})
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
192 " open cmdwin
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
193 call term_sendkeys(buf, "q:")
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
194 call WaitForAssert({-> assert_match('-- More --', term_getline(buf, 18))})
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
195 " quit more prompt for :smile command
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
196 call term_sendkeys(buf, "q")
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
197 call WaitForAssert({-> assert_match('^$', term_getline(buf, 18))})
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
198 " execute a simple command
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
199 call term_sendkeys(buf, "aecho 'done'\<CR>")
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
200 call VerifyScreenDump(buf, 'Test_cmdwin_interrupted', {})
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
201
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
202 " clean up
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
203 call StopVimInTerminal(buf)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
204 call delete('XTest_cmdwin')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
205 endfunc
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
206
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
207 " Test for recursively getting multiple command line inputs
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
208 func Test_cmdwin_multi_input()
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
209 call feedkeys(":\<C-R>=input('P: ')\<CR>\"cyan\<CR>\<CR>", 'xt')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
210 call assert_equal('"cyan', @:)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
211 endfunc
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
212
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
213 " Test for normal mode commands not supported in the cmd window
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
214 func Test_cmdwin_blocked_commands()
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
215 call assert_fails('call feedkeys("q:\<C-T>\<CR>", "xt")', 'E11:')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
216 call assert_fails('call feedkeys("q:\<C-]>\<CR>", "xt")', 'E11:')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
217 call assert_fails('call feedkeys("q:\<C-^>\<CR>", "xt")', 'E11:')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
218 call assert_fails('call feedkeys("q:Q\<CR>", "xt")', 'E11:')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
219 call assert_fails('call feedkeys("q:Z\<CR>", "xt")', 'E11:')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
220 call assert_fails('call feedkeys("q:\<F1>\<CR>", "xt")', 'E11:')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
221 call assert_fails('call feedkeys("q:\<C-W>s\<CR>", "xt")', 'E11:')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
222 call assert_fails('call feedkeys("q:\<C-W>v\<CR>", "xt")', 'E11:')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
223 call assert_fails('call feedkeys("q:\<C-W>^\<CR>", "xt")', 'E11:')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
224 call assert_fails('call feedkeys("q:\<C-W>n\<CR>", "xt")', 'E11:')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
225 call assert_fails('call feedkeys("q:\<C-W>z\<CR>", "xt")', 'E11:')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
226 call assert_fails('call feedkeys("q:\<C-W>o\<CR>", "xt")', 'E11:')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
227 call assert_fails('call feedkeys("q:\<C-W>w\<CR>", "xt")', 'E11:')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
228 call assert_fails('call feedkeys("q:\<C-W>j\<CR>", "xt")', 'E11:')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
229 call assert_fails('call feedkeys("q:\<C-W>k\<CR>", "xt")', 'E11:')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
230 call assert_fails('call feedkeys("q:\<C-W>h\<CR>", "xt")', 'E11:')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
231 call assert_fails('call feedkeys("q:\<C-W>l\<CR>", "xt")', 'E11:')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
232 call assert_fails('call feedkeys("q:\<C-W>T\<CR>", "xt")', 'E11:')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
233 call assert_fails('call feedkeys("q:\<C-W>x\<CR>", "xt")', 'E11:')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
234 call assert_fails('call feedkeys("q:\<C-W>r\<CR>", "xt")', 'E11:')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
235 call assert_fails('call feedkeys("q:\<C-W>R\<CR>", "xt")', 'E11:')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
236 call assert_fails('call feedkeys("q:\<C-W>K\<CR>", "xt")', 'E11:')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
237 call assert_fails('call feedkeys("q:\<C-W>}\<CR>", "xt")', 'E11:')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
238 call assert_fails('call feedkeys("q:\<C-W>]\<CR>", "xt")', 'E11:')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
239 call assert_fails('call feedkeys("q:\<C-W>f\<CR>", "xt")', 'E11:')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
240 call assert_fails('call feedkeys("q:\<C-W>d\<CR>", "xt")', 'E11:')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
241 call assert_fails('call feedkeys("q:\<C-W>g\<CR>", "xt")', 'E11:')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
242 endfunc
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
243
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
244 " Close the Cmd-line window in insert mode using CTRL-C
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
245 func Test_cmdwin_insert_mode_close()
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
246 %bw!
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
247 let s = ''
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
248 exe "normal q:a\<C-C>let s='Hello'\<CR>"
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
249 call assert_equal('Hello', s)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
250 call assert_equal(1, winnr('$'))
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
251 endfunc
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
252
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
253 func Test_cmdwin_ex_mode_with_modifier()
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
254 " this was accessing memory after allocated text in Ex mode
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
255 new
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
256 call setline(1, ['some', 'text', 'lines'])
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
257 silent! call feedkeys("gQnormal vq:atopleft\<C-V>\<CR>\<CR>", 'xt')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
258 bwipe!
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
259 endfunc
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
260
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
261 func s:ComplInCmdwin_GlobalCompletion(a, l, p)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
262 return 'global'
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
263 endfunc
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
264
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
265 func s:ComplInCmdwin_LocalCompletion(a, l, p)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
266 return 'local'
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
267 endfunc
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
268
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
269 func Test_compl_in_cmdwin()
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
270 set wildmenu wildchar=<Tab>
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
271 com! -nargs=1 -complete=command GetInput let input = <q-args>
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
272 com! -buffer TestCommand echo 'TestCommand'
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
273 let w:test_winvar = 'winvar'
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
274 let b:test_bufvar = 'bufvar'
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
275
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
276 " User-defined commands
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
277 let input = ''
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
278 call feedkeys("q:iGetInput T\<C-x>\<C-v>\<CR>", 'tx!')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
279 call assert_equal('TestCommand', input)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
280
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
281 let input = ''
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
282 call feedkeys("q::GetInput T\<Tab>\<CR>:q\<CR>", 'tx!')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
283 call assert_equal('T', input)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
284
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
285
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
286 com! -nargs=1 -complete=var GetInput let input = <q-args>
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
287 " Window-local variables
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
288 let input = ''
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
289 call feedkeys("q:iGetInput w:test_\<C-x>\<C-v>\<CR>", 'tx!')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
290 call assert_equal('w:test_winvar', input)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
291
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
292 let input = ''
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
293 call feedkeys("q::GetInput w:test_\<Tab>\<CR>:q\<CR>", 'tx!')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
294 call assert_equal('w:test_', input)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
295
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
296 " Buffer-local variables
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
297 let input = ''
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
298 call feedkeys("q:iGetInput b:test_\<C-x>\<C-v>\<CR>", 'tx!')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
299 call assert_equal('b:test_bufvar', input)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
300
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
301 let input = ''
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
302 call feedkeys("q::GetInput b:test_\<Tab>\<CR>:q\<CR>", 'tx!')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
303 call assert_equal('b:test_', input)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
304
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
305
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
306 " Argument completion of buffer-local command
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
307 func s:ComplInCmdwin_GlobalCompletionList(a, l, p)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
308 return ['global']
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
309 endfunc
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
310
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
311 func s:ComplInCmdwin_LocalCompletionList(a, l, p)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
312 return ['local']
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
313 endfunc
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
314
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
315 func s:ComplInCmdwin_CheckCompletion(arg)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
316 call assert_equal('local', a:arg)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
317 endfunc
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
318
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
319 com! -nargs=1 -complete=custom,<SID>ComplInCmdwin_GlobalCompletion
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
320 \ TestCommand call s:ComplInCmdwin_CheckCompletion(<q-args>)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
321 com! -buffer -nargs=1 -complete=custom,<SID>ComplInCmdwin_LocalCompletion
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
322 \ TestCommand call s:ComplInCmdwin_CheckCompletion(<q-args>)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
323 call feedkeys("q:iTestCommand \<Tab>\<CR>", 'tx!')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
324
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
325 com! -nargs=1 -complete=customlist,<SID>ComplInCmdwin_GlobalCompletionList
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
326 \ TestCommand call s:ComplInCmdwin_CheckCompletion(<q-args>)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
327 com! -buffer -nargs=1 -complete=customlist,<SID>ComplInCmdwin_LocalCompletionList
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
328 \ TestCommand call s:ComplInCmdwin_CheckCompletion(<q-args>)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
329
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
330 call feedkeys("q:iTestCommand \<Tab>\<CR>", 'tx!')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
331
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
332 func! s:ComplInCmdwin_CheckCompletion(arg)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
333 call assert_equal('global', a:arg)
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
334 endfunc
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
335 new
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
336 call feedkeys("q:iTestCommand \<Tab>\<CR>", 'tx!')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
337 quit
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
338
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
339 delfunc s:ComplInCmdwin_GlobalCompletion
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
340 delfunc s:ComplInCmdwin_LocalCompletion
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
341 delfunc s:ComplInCmdwin_GlobalCompletionList
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
342 delfunc s:ComplInCmdwin_LocalCompletionList
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
343 delfunc s:ComplInCmdwin_CheckCompletion
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
344
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
345 delcom -buffer TestCommand
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
346 delcom TestCommand
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
347 delcom GetInput
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
348 unlet w:test_winvar
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
349 unlet b:test_bufvar
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
350 set wildmenu& wildchar&
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
351 endfunc
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
352
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
353 func Test_cmdwin_ctrl_bsl()
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
354 " Using CTRL-\ CTRL-N in cmd window should close the window
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
355 call feedkeys("q:\<C-\>\<C-N>", 'xt')
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
356 call assert_equal('', getcmdwintype())
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
357 endfunc
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
358
29444
44bb4a607125 patch 9.0.0064: confusing error when using "q:" in command line window
Bram Moolenaar <Bram@vim.org>
parents: 29369
diff changeset
359 func Test_cant_open_cmdwin_in_cmdwin()
44bb4a607125 patch 9.0.0064: confusing error when using "q:" in command line window
Bram Moolenaar <Bram@vim.org>
parents: 29369
diff changeset
360 try
44bb4a607125 patch 9.0.0064: confusing error when using "q:" in command line window
Bram Moolenaar <Bram@vim.org>
parents: 29369
diff changeset
361 call feedkeys("q:q::q\<CR>", "x!")
44bb4a607125 patch 9.0.0064: confusing error when using "q:" in command line window
Bram Moolenaar <Bram@vim.org>
parents: 29369
diff changeset
362 catch
44bb4a607125 patch 9.0.0064: confusing error when using "q:" in command line window
Bram Moolenaar <Bram@vim.org>
parents: 29369
diff changeset
363 let caught = v:exception
44bb4a607125 patch 9.0.0064: confusing error when using "q:" in command line window
Bram Moolenaar <Bram@vim.org>
parents: 29369
diff changeset
364 endtry
44bb4a607125 patch 9.0.0064: confusing error when using "q:" in command line window
Bram Moolenaar <Bram@vim.org>
parents: 29369
diff changeset
365 call assert_match('E1292:', caught)
44bb4a607125 patch 9.0.0064: confusing error when using "q:" in command line window
Bram Moolenaar <Bram@vim.org>
parents: 29369
diff changeset
366 endfunc
44bb4a607125 patch 9.0.0064: confusing error when using "q:" in command line window
Bram Moolenaar <Bram@vim.org>
parents: 29369
diff changeset
367
29369
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
368
b1f345ec827e patch 9.0.0027: the command line test is getting quite big
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
369 " vim: shiftwidth=2 sts=2 expandtab