diff options
Diffstat (limited to 'src/nvim/window.c')
-rw-r--r-- | src/nvim/window.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c index fefbab822e..eddbe14da2 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -5,7 +5,6 @@ #include <inttypes.h> #include <stdbool.h> -#include "nvim/api/private/handle.h" #include "nvim/api/private/helpers.h" #include "nvim/vim.h" #include "nvim/ascii.h" @@ -2605,7 +2604,7 @@ void win_close_othertab(win_T *win, int free_buf, tabpage_T *tp) { int dir; tabpage_T *ptp = NULL; - int free_tp = FALSE; + bool free_tp = false; // Get here with win->w_buffer == NULL when win_close() detects the tab page // changed. @@ -2710,7 +2709,11 @@ static win_T *win_free_mem( // When deleting the current window of another tab page select a new // current window. if (tp != NULL && win == tp->tp_curwin) { - tp->tp_curwin = wp; + if (win_valid(tp->tp_prevwin) && tp->tp_prevwin != win) { + tp->tp_curwin = tp->tp_prevwin; + } else { + tp->tp_curwin = tp->tp_firstwin; + } } return wp; @@ -3601,7 +3604,7 @@ static tabpage_T *alloc_tabpage(void) static int last_tp_handle = 0; tabpage_T *tp = xcalloc(1, sizeof(tabpage_T)); tp->handle = ++last_tp_handle; - handle_register_tabpage(tp); + pmap_put(handle_T)(&tabpage_handles, tp->handle, tp); // Init t: variables. tp->tp_vars = tv_dict_alloc(); @@ -3616,7 +3619,7 @@ void free_tabpage(tabpage_T *tp) { int idx; - handle_unregister_tabpage(tp); + pmap_del(handle_T)(&tabpage_handles, tp->handle); diff_clear(tp); for (idx = 0; idx < SNAP_COUNT; ++idx) clear_snapshot(tp, idx); @@ -4545,7 +4548,7 @@ static win_T *win_alloc(win_T *after, bool hidden) win_T *new_wp = xcalloc(1, sizeof(win_T)); new_wp->handle = ++last_win_id; - handle_register_window(new_wp); + pmap_put(handle_T)(&window_handles, new_wp->handle, new_wp); grid_assign_handle(&new_wp->w_grid_alloc); @@ -4616,7 +4619,7 @@ win_free ( int i; wininfo_T *wip; - handle_unregister_window(wp); + pmap_del(handle_T)(&window_handles, wp->handle); clearFolding(wp); /* reduce the reference count to the argument list. */ |