From 929293815bc6b9b1b5fdd129970c4e2f7279a6d6 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Thu, 31 Mar 2022 09:59:14 +0100 Subject: fix(api): improve autocmd error handling - nvim_del_augroup_* now works with pcall - nvim_del_autocmd now errors for invalid ids --- test/functional/api/autocmd_spec.lua | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test') diff --git a/test/functional/api/autocmd_spec.lua b/test/functional/api/autocmd_spec.lua index b8fbd4f9a5..25220f7e74 100644 --- a/test/functional/api/autocmd_spec.lua +++ b/test/functional/api/autocmd_spec.lua @@ -809,6 +809,14 @@ describe('autocmd api', function() eq(2, get_executed_count(), "No additional counts") end) + it('can delete non-existent groups with pcall', function() + eq(false, exec_lua[[return pcall(vim.api.nvim_del_augroup_by_name, 'noexist')]]) + eq('Vim:E367: No such group: "noexist"', pcall_err(meths.del_augroup_by_name, 'noexist')) + + eq(false, exec_lua[[return pcall(vim.api.nvim_del_augroup_by_id, -12342)]]) + eq('Vim:E367: No such group: "--Deleted--"', pcall_err(meths.del_augroup_by_id, -12312)) + end) + it('groups work with once', function() local augroup = "TestGroup" -- cgit