mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00
vim-patch:8.2.1748: closing split window in other tab may cause a crash
Problem: Closing split window in other tab may cause a crash.
Solution: Set tp_curwin properly. (Rob Pilling, closes vim/vim#7018)
f3c51bbff1
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
@@ -192,7 +192,23 @@ func Test_tabwin_close()
|
|||||||
call win_execute(l:wid, 'close')
|
call win_execute(l:wid, 'close')
|
||||||
" Should not crash.
|
" Should not crash.
|
||||||
call assert_true(v:true)
|
call assert_true(v:true)
|
||||||
%bwipe!
|
|
||||||
|
" This tests closing a window in another tab, while leaving the tab open
|
||||||
|
" i.e. two windows in another tab.
|
||||||
|
tabedit
|
||||||
|
let w:this_win = 42
|
||||||
|
new
|
||||||
|
let othertab_wid = win_getid()
|
||||||
|
tabprevious
|
||||||
|
call win_execute(othertab_wid, 'q')
|
||||||
|
" drawing the tabline helps check that the other tab's windows and buffers
|
||||||
|
" are still valid
|
||||||
|
redrawtabline
|
||||||
|
" but to be certain, ensure we can focus the other tab too
|
||||||
|
tabnext
|
||||||
|
call assert_equal(42, w:this_win)
|
||||||
|
|
||||||
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Test when closing a split window (above/below) restores space to the window
|
" Test when closing a split window (above/below) restores space to the window
|
||||||
|
@@ -3058,6 +3058,7 @@ void win_close_othertab(win_T *win, int free_buf, tabpage_T *tp)
|
|||||||
static win_T *win_free_mem(win_T *win, int *dirp, tabpage_T *tp)
|
static win_T *win_free_mem(win_T *win, int *dirp, tabpage_T *tp)
|
||||||
{
|
{
|
||||||
win_T *wp;
|
win_T *wp;
|
||||||
|
tabpage_T *win_tp = tp == NULL ? curtab : tp;
|
||||||
|
|
||||||
if (!win->w_floating) {
|
if (!win->w_floating) {
|
||||||
// Remove the window and its frame from the tree of frames.
|
// Remove the window and its frame from the tree of frames.
|
||||||
@@ -3082,10 +3083,10 @@ static win_T *win_free_mem(win_T *win, int *dirp, tabpage_T *tp)
|
|||||||
}
|
}
|
||||||
win_free(win, tp);
|
win_free(win, tp);
|
||||||
|
|
||||||
// When deleting the current window of another tab page select a new
|
// When deleting the current window in the tab, select a new current
|
||||||
// current window.
|
// window.
|
||||||
if (tp != NULL && win == tp->tp_curwin) {
|
if (win == win_tp->tp_curwin) {
|
||||||
tp->tp_curwin = wp;
|
win_tp->tp_curwin = wp;
|
||||||
}
|
}
|
||||||
|
|
||||||
return wp;
|
return wp;
|
||||||
|
Reference in New Issue
Block a user