diff options
author | luukvbaal <luukvbaal@gmail.com> | 2024-12-17 13:12:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-17 04:12:22 -0800 |
commit | 6bf2a6fc5bb395b67c88cb26d332f882a106c7ab (patch) | |
tree | 44259c3b4df40c5af3a4bacec308945f93365d6e /src/nvim/api/private/helpers.h | |
parent | b03e790cddd19b57fa91f4fbfcc30c28f3c173bf (diff) | |
download | rneovim-6bf2a6fc5bb395b67c88cb26d332f882a106c7ab.tar.gz rneovim-6bf2a6fc5bb395b67c88cb26d332f882a106c7ab.tar.bz2 rneovim-6bf2a6fc5bb395b67c88cb26d332f882a106c7ab.zip |
refactor(api): always use TRY_WRAP #31600
Problem: Two separate try/end wrappers, that only marginally differ by
restoring a few variables. Wrappers that don't restore
previous state are dangerous to use in "api-fast" functions.
Solution: Remove wrappers that don't restore the previous state.
Always use TRY_WRAP.
Diffstat (limited to 'src/nvim/api/private/helpers.h')
-rw-r--r-- | src/nvim/api/private/helpers.h | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/src/nvim/api/private/helpers.h b/src/nvim/api/private/helpers.h index d06f5c9c65..03ff811449 100644 --- a/src/nvim/api/private/helpers.h +++ b/src/nvim/api/private/helpers.h @@ -147,27 +147,19 @@ typedef struct { except_T *current_exception; msglist_T *private_msg_list; const msglist_T *const *msg_list; - int trylevel; int got_int; bool did_throw; int need_rethrow; int did_emsg; } TryState; -// `msg_list` controls the collection of abort-causing non-exception errors, -// which would otherwise be ignored. This pattern is from do_cmdline(). -// // TODO(bfredl): prepare error-handling at "top level" (nv_event). #define TRY_WRAP(err, code) \ do { \ - msglist_T **saved_msg_list = msg_list; \ - msglist_T *private_msg_list; \ - msg_list = &private_msg_list; \ - private_msg_list = NULL; \ - try_start(); \ + TryState tstate; \ + try_enter(&tstate); \ code; \ - try_end(err); \ - msg_list = saved_msg_list; /* Restore the exception context. */ \ + try_leave(&tstate, err); \ } while (0) // Execute code with cursor position saved and restored and textlock active. |