patch 9.0.1470: deferred functions invoked in unexpected order
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 #12278)
diff --git a/src/userfunc.c b/src/userfunc.c
index 0680767..fbde6ed 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -6144,12 +6144,12 @@
void
invoke_all_defer(void)
{
+ for (funccall_T *fc = current_funccal; fc != NULL; fc = fc->fc_caller)
+ invoke_funccall_defer(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)
invoke_funccall_defer(fc);
-
- for (funccall_T *fc = current_funccal; fc != NULL; fc = fc->fc_caller)
- invoke_funccall_defer(fc);
}
/*