diff options
Diffstat (limited to 'src/nvim/api/window.c')
-rw-r--r-- | src/nvim/api/window.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c index 08dcc113da..e2c234ab29 100644 --- a/src/nvim/api/window.c +++ b/src/nvim/api/window.c @@ -10,16 +10,18 @@ #include "nvim/api/private/helpers.h" #include "nvim/api/window.h" #include "nvim/ascii.h" -#include "nvim/buffer.h" +#include "nvim/buffer_defs.h" #include "nvim/cursor.h" #include "nvim/drawscreen.h" +#include "nvim/eval/window.h" #include "nvim/ex_docmd.h" +#include "nvim/gettext.h" #include "nvim/globals.h" #include "nvim/lua/executor.h" +#include "nvim/memline_defs.h" #include "nvim/move.h" -#include "nvim/option.h" -#include "nvim/syntax.h" -#include "nvim/vim.h" +#include "nvim/pos.h" +#include "nvim/types.h" #include "nvim/window.h" /// Gets the current buffer in a window @@ -117,8 +119,13 @@ void nvim_win_set_cursor(Window window, ArrayOf(Integer, 2) pos, Error *err) // Make sure we stick in this column. win->w_set_curswant = true; - // make sure cursor is in visible range even if win != curwin - update_topline_win(win); + // make sure cursor is in visible range and + // cursorcolumn and cursorline are updated even if win != curwin + switchwin_T switchwin; + switch_win(&switchwin, win, NULL, true); + update_topline(curwin); + validate_cursor(); + restore_win(&switchwin, true); redraw_later(win, UPD_VALID); win->w_redr_status = true; @@ -162,9 +169,11 @@ void nvim_win_set_height(Window window, Integer height, Error *err) win_T *savewin = curwin; curwin = win; + curbuf = curwin->w_buffer; try_start(); win_setheight((int)height); curwin = savewin; + curbuf = curwin->w_buffer; try_end(err); } @@ -207,9 +216,11 @@ void nvim_win_set_width(Window window, Integer width, Error *err) win_T *savewin = curwin; curwin = win; + curbuf = curwin->w_buffer; try_start(); win_setwidth((int)width); curwin = savewin; + curbuf = curwin->w_buffer; try_end(err); } @@ -358,11 +369,16 @@ void nvim_win_hide(Window window, Error *err) tabpage_T *tabpage = win_find_tabpage(win); TryState tstate; try_enter(&tstate); - if (tabpage == curtab) { + + // 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); } |