diff options
author | Lewis Russell <lewis6991@gmail.com> | 2022-03-31 09:59:14 +0100 |
---|---|---|
committer | Lewis Russell <lewis6991@gmail.com> | 2022-03-31 14:23:53 +0100 |
commit | 929293815bc6b9b1b5fdd129970c4e2f7279a6d6 (patch) | |
tree | cb9dbc314fc835238a72b0da84f03eb63f8e0063 /src/nvim/autocmd.c | |
parent | 1184097261260e53519db54548acf2c1e5ab7e68 (diff) | |
download | rneovim-929293815bc6b9b1b5fdd129970c4e2f7279a6d6.tar.gz rneovim-929293815bc6b9b1b5fdd129970c4e2f7279a6d6.tar.bz2 rneovim-929293815bc6b9b1b5fdd129970c4e2f7279a6d6.zip |
fix(api): improve autocmd error handling
- nvim_del_augroup_* now works with pcall
- nvim_del_autocmd now errors for invalid ids
Diffstat (limited to 'src/nvim/autocmd.c')
-rw-r--r-- | src/nvim/autocmd.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index d4af05b961..c0a22d058c 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -2350,17 +2350,20 @@ int autocmd_delete_event(int group, event_T event, char_u *pat) /// Deletes an autocmd by ID. /// Only autocmds created via the API have IDs associated with them. There /// is no way to delete a specific autocmd created via :autocmd -void autocmd_delete_id(int64_t id) +bool autocmd_delete_id(int64_t id) { + assert(id > 0); FOR_ALL_AUEVENTS(event) { FOR_ALL_AUPATS_IN_EVENT(event, ap) { for (AutoCmd *ac = ap->cmds; ac != NULL; ac = ac->next) { if (ac->id == id) { aucmd_del(ac); + return true; } } } } + return false; } // =========================================================================== |