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)

1be4b81bfb
This commit is contained in:
zeertzjq
2023-04-19 22:09:48 +08:00
committed by GitHub
parent 7bf1a917b7
commit 0d7bed34a2
2 changed files with 35 additions and 17 deletions

View File

@@ -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.