diff options
author | Lewis Russell <lewis6991@gmail.com> | 2022-04-01 08:38:58 +0100 |
---|---|---|
committer | Lewis Russell <lewis6991@gmail.com> | 2022-04-01 08:38:58 +0100 |
commit | dc3bbd31a9d6c36944b7f26127d9d46b21a70c2f (patch) | |
tree | 3dab7a794ca2d16caad40a5354cb0805fbe16cbf | |
parent | 973e91007ce3f343f7aeed8d30d70a8616ab6bb5 (diff) | |
download | rneovim-dc3bbd31a9d6c36944b7f26127d9d46b21a70c2f.tar.gz rneovim-dc3bbd31a9d6c36944b7f26127d9d46b21a70c2f.tar.bz2 rneovim-dc3bbd31a9d6c36944b7f26127d9d46b21a70c2f.zip |
fix(api): delete all autocmds with the same ID
-rw-r--r-- | src/nvim/autocmd.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index c0a22d058c..bcac7fbc4a 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -2353,17 +2353,20 @@ int autocmd_delete_event(int group, event_T event, char_u *pat) bool autocmd_delete_id(int64_t id) { assert(id > 0); + bool success = false; + + // Note that since multiple AutoCmd objects can have the same ID, we need to do a full scan. 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; + success = true; } } } } - return false; + return success; } // =========================================================================== |