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.
This commit is contained in:
luukvbaal
2024-12-17 13:12:22 +01:00
committed by GitHub
parent b03e790cdd
commit 6bf2a6fc5b
10 changed files with 377 additions and 427 deletions

View File

@@ -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;