aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/vimscript.c
diff options
context:
space:
mode:
authorluukvbaal <luukvbaal@gmail.com>2024-12-17 13:12:22 +0100
committerGitHub <noreply@github.com>2024-12-17 04:12:22 -0800
commit6bf2a6fc5bb395b67c88cb26d332f882a106c7ab (patch)
tree44259c3b4df40c5af3a4bacec308945f93365d6e /src/nvim/api/vimscript.c
parentb03e790cddd19b57fa91f4fbfcc30c28f3c173bf (diff)
downloadrneovim-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/vimscript.c')
-rw-r--r--src/nvim/api/vimscript.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/nvim/api/vimscript.c b/src/nvim/api/vimscript.c
index 0ff2b037ce..67db615b20 100644
--- a/src/nvim/api/vimscript.c
+++ b/src/nvim/api/vimscript.c
@@ -78,24 +78,24 @@ String exec_impl(uint64_t channel_id, String src, Dict(exec_opts) *opts, Error *
capture_ga = &capture_local;
}
- try_start();
- if (opts->output) {
- msg_silent++;
- msg_col = 0; // prevent leading spaces
- }
+ TRY_WRAP(err, {
+ if (opts->output) {
+ msg_silent++;
+ msg_col = 0; // prevent leading spaces
+ }
- const sctx_T save_current_sctx = api_set_sctx(channel_id);
+ const sctx_T save_current_sctx = api_set_sctx(channel_id);
- do_source_str(src.data, "nvim_exec2()");
- if (opts->output) {
- capture_ga = save_capture_ga;
- msg_silent = save_msg_silent;
- // Put msg_col back where it was, since nothing should have been written.
- msg_col = save_msg_col;
- }
+ do_source_str(src.data, "nvim_exec2()");
+ if (opts->output) {
+ capture_ga = save_capture_ga;
+ msg_silent = save_msg_silent;
+ // Put msg_col back where it was, since nothing should have been written.
+ msg_col = save_msg_col;
+ }
- current_sctx = save_current_sctx;
- try_end(err);
+ current_sctx = save_current_sctx;
+ });
if (ERROR_SET(err)) {
goto theend;