mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 05:58:33 +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:
@@ -623,38 +623,32 @@ static int nlua_with(lua_State *L)
|
||||
cmdmod.cmod_flags = flags;
|
||||
apply_cmdmod(&cmdmod);
|
||||
|
||||
if (buf || win) {
|
||||
try_start();
|
||||
}
|
||||
|
||||
aco_save_T aco;
|
||||
win_execute_T win_execute_args;
|
||||
Error err = ERROR_INIT;
|
||||
TRY_WRAP(&err, {
|
||||
aco_save_T aco;
|
||||
win_execute_T win_execute_args;
|
||||
|
||||
if (win) {
|
||||
tabpage_T *tabpage = win_find_tabpage(win);
|
||||
if (!win_execute_before(&win_execute_args, win, tabpage)) {
|
||||
goto end;
|
||||
if (win) {
|
||||
tabpage_T *tabpage = win_find_tabpage(win);
|
||||
if (!win_execute_before(&win_execute_args, win, tabpage)) {
|
||||
goto end;
|
||||
}
|
||||
} else if (buf) {
|
||||
aucmd_prepbuf(&aco, buf);
|
||||
}
|
||||
} else if (buf) {
|
||||
aucmd_prepbuf(&aco, buf);
|
||||
}
|
||||
|
||||
int s = lua_gettop(L);
|
||||
lua_pushvalue(L, 2);
|
||||
status = lua_pcall(L, 0, LUA_MULTRET, 0);
|
||||
rets = lua_gettop(L) - s;
|
||||
int s = lua_gettop(L);
|
||||
lua_pushvalue(L, 2);
|
||||
status = lua_pcall(L, 0, LUA_MULTRET, 0);
|
||||
rets = lua_gettop(L) - s;
|
||||
|
||||
if (win) {
|
||||
win_execute_after(&win_execute_args);
|
||||
} else if (buf) {
|
||||
aucmd_restbuf(&aco);
|
||||
}
|
||||
|
||||
end:
|
||||
if (buf || win) {
|
||||
try_end(&err);
|
||||
}
|
||||
if (win) {
|
||||
win_execute_after(&win_execute_args);
|
||||
} else if (buf) {
|
||||
aucmd_restbuf(&aco);
|
||||
}
|
||||
end:;
|
||||
});
|
||||
|
||||
undo_cmdmod(&cmdmod);
|
||||
cmdmod = save_cmdmod;
|
||||
|
Reference in New Issue
Block a user