aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api/window_spec.lua
diff options
context:
space:
mode:
authorSean Dewar <seandewar@users.noreply.github.com>2023-07-23 23:10:28 +0100
committerSean Dewar <seandewar@users.noreply.github.com>2023-07-26 20:44:46 +0100
commit5d921e28c1cc33eced22bbfa823460ca241e3dc1 (patch)
treead06c2e4edc74e687f213f133557a8e085100aac /test/functional/api/window_spec.lua
parent6b4970f6e0ac36021b2a8bd0533f5078040d31f7 (diff)
downloadrneovim-5d921e28c1cc33eced22bbfa823460ca241e3dc1.tar.gz
rneovim-5d921e28c1cc33eced22bbfa823460ca241e3dc1.tar.bz2
rneovim-5d921e28c1cc33eced22bbfa823460ca241e3dc1.zip
feat(api): allow win_close in cmdwin to close wins except previous
Disallow closing the previous window from `nvim_win_close`, as this will cause issues. Again, no telling how safe this is. It also requires exposing old_curwin. :/ Also note that it's possible for the `&cmdheight` to change if, for example, there are 2 tabpages and `nvim_win_close` is used to close the last window in the other tabpage while `&stal` is 1. This is addressed in a later commit.
Diffstat (limited to 'test/functional/api/window_spec.lua')
-rw-r--r--test/functional/api/window_spec.lua14
1 files changed, 10 insertions, 4 deletions
diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua
index e7e767817b..74aaae0c6f 100644
--- a/test/functional/api/window_spec.lua
+++ b/test/functional/api/window_spec.lua
@@ -540,15 +540,21 @@ describe('API/win', function()
command('split')
eq(2, #meths.list_wins())
local oldwin = meths.get_current_win()
+ local otherwin = meths.open_win(0, false, {
+ relative='editor', row=10, col=10, width=10, height=10,
+ })
-- Open cmdline-window.
feed('q:')
- eq(3, #meths.list_wins())
+ eq(4, #meths.list_wins())
eq(':', funcs.getcmdwintype())
- -- Vim: not allowed to close other windows from cmdline-window.
+ -- Not allowed to close previous window from cmdline-window.
eq('E11: Invalid in command-line window; <CR> executes, CTRL-C quits',
- pcall_err(meths.win_close, oldwin, true))
+ pcall_err(meths.win_close, oldwin, true))
+ -- Closing other windows is fine.
+ meths.win_close(otherwin, true)
+ eq(false, meths.win_is_valid(otherwin))
-- Close cmdline-window.
- meths.win_close(0,true)
+ meths.win_close(0, true)
eq(2, #meths.list_wins())
eq('', funcs.getcmdwintype())
end)