From 0d7bed34a29ef1add5d225a6809882fa6dce49d9 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 19 Apr 2023 22:09:48 +0800 Subject: vim-patch:9.0.1470: deferred functions invoked in unexpected order (#23199) Problem: Deferred functions invoked in unexpected order when using :qa and autocommands. Solution: Call deferred functions for the current funccal before using the stack. (closes vim/vim#12278) https://github.com/vim/vim/commit/1be4b81bfb3d7edf0e2ae41711d429e8fa5e0555 --- src/nvim/eval/userfunc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 4cb2f9bd2b..51e109fdfb 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -3270,15 +3270,15 @@ static void handle_defer_one(funccall_T *funccal) /// Called when exiting: call all defer functions. void invoke_all_defer(void) { + for (funccall_T *fc = current_funccal; fc != NULL; fc = fc->fc_caller) { + handle_defer_one(fc); + } + for (funccal_entry_T *fce = funccal_stack; fce != NULL; fce = fce->next) { for (funccall_T *fc = fce->top_funccal; fc != NULL; fc = fc->fc_caller) { handle_defer_one(fc); } } - - for (funccall_T *fc = current_funccal; fc != NULL; fc = fc->fc_caller) { - handle_defer_one(fc); - } } /// ":1,25call func(arg1, arg2)" function call. -- cgit