mirror of
https://github.com/neovim/neovim.git
synced 2025-09-19 01:38:16 +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:
@@ -368,19 +368,16 @@ void nvim_win_hide(Window window, Error *err)
|
||||
}
|
||||
|
||||
tabpage_T *tabpage = win_find_tabpage(win);
|
||||
TryState tstate;
|
||||
try_enter(&tstate);
|
||||
|
||||
// Never close the autocommand window.
|
||||
if (is_aucmd_win(win)) {
|
||||
emsg(_(e_autocmd_close));
|
||||
} else if (tabpage == curtab) {
|
||||
win_close(win, false, false);
|
||||
} else {
|
||||
win_close_othertab(win, false, tabpage);
|
||||
}
|
||||
|
||||
vim_ignored = try_leave(&tstate, err);
|
||||
TRY_WRAP(err, {
|
||||
// Never close the autocommand window.
|
||||
if (is_aucmd_win(win)) {
|
||||
emsg(_(e_autocmd_close));
|
||||
} else if (tabpage == curtab) {
|
||||
win_close(win, false, false);
|
||||
} else {
|
||||
win_close_othertab(win, false, tabpage);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// Closes the window (like |:close| with a |window-ID|).
|
||||
@@ -400,10 +397,9 @@ void nvim_win_close(Window window, Boolean force, Error *err)
|
||||
}
|
||||
|
||||
tabpage_T *tabpage = win_find_tabpage(win);
|
||||
TryState tstate;
|
||||
try_enter(&tstate);
|
||||
ex_win_close(force, win, tabpage == curtab ? NULL : tabpage);
|
||||
vim_ignored = try_leave(&tstate, err);
|
||||
TRY_WRAP(err, {
|
||||
ex_win_close(force, win, tabpage == curtab ? NULL : tabpage);
|
||||
});
|
||||
}
|
||||
|
||||
/// Calls a function with window as temporary current window.
|
||||
|
Reference in New Issue
Block a user