aboutsummaryrefslogtreecommitdiff
path: root/test/functional/autocmd/autocmd_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/autocmd/autocmd_spec.lua')
-rw-r--r--test/functional/autocmd/autocmd_spec.lua42
1 files changed, 38 insertions, 4 deletions
diff --git a/test/functional/autocmd/autocmd_spec.lua b/test/functional/autocmd/autocmd_spec.lua
index 90254b7415..fb5bab445c 100644
--- a/test/functional/autocmd/autocmd_spec.lua
+++ b/test/functional/autocmd/autocmd_spec.lua
@@ -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
@@ -424,17 +425,50 @@ describe('autocmd', function()
end)
it('gives E814 when there are no other floating windows', function()
- eq('Vim(close):E814: Cannot close window, only autocmd window would remain',
+ eq('BufAdd Autocommands for "Xa.txt": Vim(close):E814: Cannot close window, only autocmd window would remain',
pcall_err(command, 'doautoall BufAdd'))
end)
it('gives E814 when there are other floating windows', function()
meths.open_win(0, true, {width = 10, height = 10, relative = 'editor', row = 10, col = 10})
- eq('Vim(close):E814: Cannot close window, only autocmd window would remain',
+ eq('BufAdd Autocommands for "Xa.txt": Vim(close):E814: Cannot close window, only autocmd window would remain',
pcall_err(command, 'doautoall BufAdd'))
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()
@@ -476,14 +510,14 @@ describe('autocmd', function()
it('during RecordingLeave event', function()
command([[autocmd RecordingLeave * let v:event.regname = '']])
- eq('Vim(let):E46: Cannot change read-only variable "v:event.regname"',
+ eq('RecordingLeave Autocommands for "*": Vim(let):E46: Cannot change read-only variable "v:event.regname"',
pcall_err(command, 'normal! qqq'))
end)
it('during TermClose event', function()
command('autocmd TermClose * let v:event.status = 0')
command('terminal')
- eq('Vim(let):E46: Cannot change read-only variable "v:event.status"',
+ eq('TermClose Autocommands for "*": Vim(let):E46: Cannot change read-only variable "v:event.status"',
pcall_err(command, 'bdelete!'))
end)
end)