Merge pull request #14091 from euclidianAce/euclidianAce/nvim_win_hide

api: add vim.api.nvim_win_hide
This commit is contained in:
Björn Linse
2021-03-28 19:07:56 +02:00
committed by GitHub
3 changed files with 84 additions and 0 deletions

View File

@@ -492,6 +492,35 @@ Dictionary nvim_win_get_config(Window window, Error *err)
return rv;
}
/// Closes the window and hide the buffer it contains (like |:hide| with a
/// |window-ID|).
///
/// Like |:hide| the buffer becomes hidden unless another window is editing it,
/// or 'bufhidden' is `unload`, `delete` or `wipe` as opposed to |:close| or
/// |nvim_win_close|, which will close the buffer.
///
/// @param window Window handle, or 0 for current window
/// @param[out] err Error details, if any
void nvim_win_hide(Window window, Error *err)
FUNC_API_SINCE(7)
FUNC_API_CHECK_TEXTLOCK
{
win_T *win = find_window_by_handle(window, err);
if (!win) {
return;
}
tabpage_T *tabpage = win_find_tabpage(win);
TryState tstate;
try_enter(&tstate);
if (tabpage == curtab) {
win_close(win, false);
} else {
win_close_othertab(win, false, tabpage);
}
vim_ignored = try_leave(&tstate, err);
}
/// Closes the window (like |:close| with a |window-ID|).
///
/// @param window Window handle, or 0 for current window