diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-10-18 18:27:50 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2023-10-18 18:29:47 +0800 |
commit | 9e3640a7797bcc5f6015548842572a6ce951a861 (patch) | |
tree | 477412bf56978d009949982a89b1102a0d8b156b /src/nvim | |
parent | 831d662ac6756cab4fed6a9b394e68933b5fe325 (diff) | |
download | rneovim-9e3640a7797bcc5f6015548842572a6ce951a861.tar.gz rneovim-9e3640a7797bcc5f6015548842572a6ce951a861.tar.bz2 rneovim-9e3640a7797bcc5f6015548842572a6ce951a861.zip |
vim-patch:9.0.2044: Vim9: exceptions confuse defered functions
Problem: Vim9: exceptions confuse defered functions
Solution: save and restore exception state when calling defered
functions
closes: vim/vim#13364
closes: vim/vim#13372
https://github.com/vim/vim/commit/0672595fd50e9ae668676a40e28ebf66d7f52392
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/nvim')
-rw-r--r-- | src/nvim/eval/userfunc.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index ca98aad6bc..f789c53870 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -3296,8 +3296,23 @@ static void handle_defer_one(funccall_T *funccal) char *name = dr->dr_name; dr->dr_name = NULL; + // If the deferred function is called after an exception, then only the + // first statement in the function will be executed. Save and restore + // the try/catch/throw exception state. + const int save_trylevel = trylevel; + const bool save_did_throw = did_throw; + const bool save_need_rethrow = need_rethrow; + + trylevel = 0; + did_throw = false; + need_rethrow = false; + call_func(name, -1, &rettv, dr->dr_argcount, dr->dr_argvars, &funcexe); + trylevel = save_trylevel; + did_throw = save_did_throw; + need_rethrow = save_need_rethrow; + tv_clear(&rettv); xfree(name); for (int i = dr->dr_argcount - 1; i >= 0; i--) { |