mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
fix(api): don't allow hiding aucmd_win from another tabpage (#21975)
This commit is contained in:
parent
bcdbf77537
commit
fca39eeabb
@ -369,11 +369,16 @@ void nvim_win_hide(Window window, Error *err)
|
||||
tabpage_T *tabpage = win_find_tabpage(win);
|
||||
TryState tstate;
|
||||
try_enter(&tstate);
|
||||
if (tabpage == curtab) {
|
||||
|
||||
// Never close the autocommand window.
|
||||
if (is_aucmd_win(win)) {
|
||||
emsg(_(e_autocmd_close));
|
||||
} else if (tabpage == curtab) {
|
||||
win_close(win, false);
|
||||
} else {
|
||||
win_close_othertab(win, false, tabpage);
|
||||
}
|
||||
|
||||
vim_ignored = try_leave(&tstate, err);
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ local neq = helpers.neq
|
||||
local eval = helpers.eval
|
||||
local feed = helpers.feed
|
||||
local clear = helpers.clear
|
||||
local matches = helpers.matches
|
||||
local meths = helpers.meths
|
||||
local pcall_err = helpers.pcall_err
|
||||
local funcs = helpers.funcs
|
||||
@ -435,6 +436,39 @@ describe('autocmd', function()
|
||||
end)
|
||||
end)
|
||||
|
||||
it('closing `aucmd_win` using API gives E813', function()
|
||||
exec_lua([[
|
||||
vim.cmd('tabnew')
|
||||
_G.buf = vim.api.nvim_create_buf(true, true)
|
||||
]])
|
||||
matches('Vim:E813: Cannot close autocmd window$', pcall_err(exec_lua, [[
|
||||
vim.api.nvim_buf_call(_G.buf, function()
|
||||
local win = vim.api.nvim_get_current_win()
|
||||
vim.api.nvim_win_close(win, true)
|
||||
end)
|
||||
]]))
|
||||
matches('Vim:E813: Cannot close autocmd window$', pcall_err(exec_lua, [[
|
||||
vim.api.nvim_buf_call(_G.buf, function()
|
||||
local win = vim.api.nvim_get_current_win()
|
||||
vim.cmd('tabnext')
|
||||
vim.api.nvim_win_close(win, true)
|
||||
end)
|
||||
]]))
|
||||
matches('Vim:E813: Cannot close autocmd window$', pcall_err(exec_lua, [[
|
||||
vim.api.nvim_buf_call(_G.buf, function()
|
||||
local win = vim.api.nvim_get_current_win()
|
||||
vim.api.nvim_win_hide(win)
|
||||
end)
|
||||
]]))
|
||||
matches('Vim:E813: Cannot close autocmd window$', pcall_err(exec_lua, [[
|
||||
vim.api.nvim_buf_call(_G.buf, function()
|
||||
local win = vim.api.nvim_get_current_win()
|
||||
vim.cmd('tabnext')
|
||||
vim.api.nvim_win_hide(win)
|
||||
end)
|
||||
]]))
|
||||
end)
|
||||
|
||||
it(':doautocmd does not warn "No matching autocommands" #10689', function()
|
||||
local screen = Screen.new(32, 3)
|
||||
screen:attach()
|
||||
|
Loading…
Reference in New Issue
Block a user