0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 9.0.1469: deferred functions not called from autocommands

Problem:    Deferred functions not called from autocommands.
Solution:   Also go through the funccal_stack. (closes #12267)
This commit is contained in:
zeertzjq
2023-04-18 21:52:54 +01:00
committed by Bram Moolenaar
parent a1f2b5ddc6
commit 960cf9119e
3 changed files with 50 additions and 14 deletions

View File

@@ -6122,27 +6122,34 @@ handle_defer_one(funccall_T *funccal)
ga_clear(&funccal->fc_defer);
}
static void
invoke_funccall_defer(funccall_T *fc)
{
if (fc->fc_ectx != NULL)
{
// :def function
unwind_def_callstack(fc->fc_ectx);
may_invoke_defer_funcs(fc->fc_ectx);
}
else
{
// legacy function
handle_defer_one(fc);
}
}
/*
* Called when exiting: call all defer functions.
*/
void
invoke_all_defer(void)
{
funccall_T *funccal;
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 (funccal = current_funccal; funccal != NULL;
funccal = funccal->fc_caller)
if (funccal->fc_ectx != NULL)
{
// :def function
unwind_def_callstack(funccal->fc_ectx);
may_invoke_defer_funcs(funccal->fc_ectx);
}
else
{
// legacy function
handle_defer_one(funccal);
}
for (funccall_T *fc = current_funccal; fc != NULL; fc = fc->fc_caller)
invoke_funccall_defer(fc);
}
/*