mirror of
https://github.com/neovim/neovim.git
synced 2026-04-21 23:05:41 +00:00
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.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user