summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_cmdwin.vim
diff options
context:
space:
mode:
Diffstat (limited to 'src/testdir/test_cmdwin.vim')
-rw-r--r--src/testdir/test_cmdwin.vim115
1 files changed, 114 insertions, 1 deletions
diff --git a/src/testdir/test_cmdwin.vim b/src/testdir/test_cmdwin.vim
index 5ba16db..33a2662 100644
--- a/src/testdir/test_cmdwin.vim
+++ b/src/testdir/test_cmdwin.vim
@@ -188,7 +188,7 @@ func Test_cmdwin_tabpage()
tabclose!
endfunc
-func Test_cmdwin_interrupted()
+func Test_cmdwin_interrupted_more_prompt()
CheckScreendump
" aborting the :smile output caused the cmdline window to use the current
@@ -470,4 +470,117 @@ func Test_cmdwin_restore_heights()
set cmdheight& showtabline& laststatus&
endfunc
+func Test_cmdwin_temp_curwin()
+ func CheckWraps(expect_wrap)
+ setlocal textwidth=0 wrapmargin=1
+
+ call deletebufline('', 1, '$')
+ let as = repeat('a', winwidth(0) - 2 - &wrapmargin)
+ call setline(1, as .. ' b')
+ normal! gww
+
+ setlocal textwidth& wrapmargin&
+ call assert_equal(a:expect_wrap ? [as, 'b'] : [as .. ' b'], getline(1, '$'))
+ endfunc
+
+ func CheckCmdWin()
+ call assert_equal('command', win_gettype())
+ " textoff and &wrapmargin formatting considers the cmdwin_type char.
+ call assert_equal(1, getwininfo(win_getid())[0].textoff)
+ call CheckWraps(1)
+ endfunc
+
+ func CheckOtherWin()
+ call assert_equal('', win_gettype())
+ call assert_equal(0, getwininfo(win_getid())[0].textoff)
+ call CheckWraps(0)
+ endfunc
+
+ call feedkeys("q::call CheckCmdWin()\<CR>:call win_execute(win_getid(winnr('#')), 'call CheckOtherWin()')\<CR>:q<CR>", 'ntx')
+
+ %bwipe!
+ delfunc CheckWraps
+ delfunc CheckCmdWin
+ delfunc CheckOtherWin
+endfunc
+
+func Test_cmdwin_interrupted()
+ func CheckInterrupted()
+ call feedkeys("q::call assert_equal('', getcmdwintype())\<CR>:call assert_equal('', getcmdtype())\<CR>:q<CR>", 'ntx')
+ endfunc
+
+ augroup CmdWin
+
+ " While opening the cmdwin's split:
+ " Close the cmdwin's window.
+ au WinEnter * ++once quit
+ call CheckInterrupted()
+
+ " Close the old window.
+ au WinEnter * ++once execute winnr('#') 'quit'
+ call CheckInterrupted()
+
+ " Switch back to the old window.
+ au WinEnter * ++once wincmd p
+ call CheckInterrupted()
+
+ " Change the old window's buffer.
+ au WinEnter * ++once call win_execute(win_getid(winnr('#')), 'enew')
+ call CheckInterrupted()
+
+ " Using BufLeave autocmds as cmdwin restrictions do not apply to them when
+ " fired from opening the cmdwin...
+ " After opening the cmdwin's split, while creating the cmdwin's buffer:
+ " Delete the cmdwin's buffer.
+ au BufLeave * ++once bwipe
+ call CheckInterrupted()
+
+ " Close the cmdwin's window.
+ au BufLeave * ++once quit
+ call CheckInterrupted()
+
+ " Close the old window.
+ au BufLeave * ++once execute winnr('#') 'quit'
+ call CheckInterrupted()
+
+ " Switch to a different window.
+ au BufLeave * ++once split
+ call CheckInterrupted()
+
+ " Change the old window's buffer.
+ au BufLeave * ++once call win_execute(win_getid(winnr('#')), 'enew')
+ call CheckInterrupted()
+
+ " However, changing the current buffer is OK and does not interrupt.
+ au BufLeave * ++once edit other
+ call feedkeys("q::let t=getcmdwintype()\<CR>:let b=bufnr()\<CR>:clo<CR>", 'ntx')
+ call assert_equal(':', t)
+ call assert_equal(1, bufloaded('other'))
+ call assert_notequal(b, bufnr('other'))
+
+ augroup END
+
+ " No autocmds should remain, but clear the augroup to be sure.
+ augroup CmdWin
+ au!
+ augroup END
+
+ %bwipe!
+ delfunc CheckInterrupted
+endfunc
+
+func Test_cmdwin_existing_bufname()
+ func CheckName()
+ call assert_equal(1, getbufinfo('')[0].command)
+ call assert_equal(0, getbufinfo('[Command Line]')[0].command)
+ call assert_match('#a\s*"\[Command Line\]"', execute('ls'))
+ call assert_match('%a\s*"\[Command Line\]"', execute('ls'))
+ endfunc
+
+ file [Command Line]
+ call feedkeys("q::call CheckName()\<CR>:q\<CR>", 'ntx')
+ 0file
+ delfunc CheckName
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab