mirror of
https://github.com/neovim/neovim.git
synced 2026-05-26 06:48:27 +00:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user