vim-patch:8.0.1790: 'winfixwidth' is not always respected by :close

Problem:    'winfixwidth' is not always respected by :close.
Solution:   Prefer a frame without 'winfixwidth' or 'winfixheight'. (Jason
            Franklin)
c136af29c0
This commit is contained in:
Jan Edmund Lazo 2018-08-21 22:18:15 -04:00
parent b5fc21dbf0
commit 54e6ef73f0
2 changed files with 73 additions and 17 deletions

View File

@ -122,3 +122,39 @@ func Test_winbuf_close()
call delete('Xtest2') call delete('Xtest2')
call delete('Xtest3') call delete('Xtest3')
endfunc endfunc
" Test that ":close" will respect 'winfixheight' when possible.
func Test_winfixheight_on_close()
set nosplitbelow nosplitright
split | split | vsplit
$wincmd w
setlocal winfixheight
let l:height = winheight(0)
3close
call assert_equal(l:height, winheight(0))
%bwipeout!
setlocal nowinfixheight splitbelow& splitright&
endfunc
" Test that ":close" will respect 'winfixwidth' when possible.
func Test_winfixwidth_on_close()
set nosplitbelow nosplitright
vsplit | vsplit | split
$wincmd w
setlocal winfixwidth
let l:width = winwidth(0)
3close
call assert_equal(l:width, winwidth(0))
%bwipeout!
setlocal nowinfixwidth splitbelow& splitright&
endfunction

View File

@ -2337,14 +2337,14 @@ winframe_remove (
return wp; return wp;
} }
/* // Return a pointer to the frame that will receive the empty screen space that
* Find out which frame is going to get the freed up space when "win" is // is left over after "win" is closed.
* closed. //
* if 'splitbelow'/'splitleft' the space goes to the window above/left. // If 'splitbelow' or 'splitright' is set, the space goes above or to the left
* if 'nosplitbelow'/'nosplitleft' the space goes to the window below/right. // by default. Otherwise, the free space goes below or to the right. The
* This makes opening a window and closing it immediately keep the same window // result is that opening a window and then immediately closing it will
* layout. // preserve the initial window layout. The 'wfh' and 'wfw' settings are
*/ // respected when possible.
static frame_T * static frame_T *
win_altframe ( win_altframe (
win_T *win, win_T *win,
@ -2352,20 +2352,40 @@ win_altframe (
) )
{ {
frame_T *frp; frame_T *frp;
int b;
if (tp == NULL ? ONE_WINDOW : tp->tp_firstwin == tp->tp_lastwin) if (tp == NULL ? ONE_WINDOW : tp->tp_firstwin == tp->tp_lastwin) {
/* Last window in this tab page, will go to next tab page. */
return alt_tabpage()->tp_curwin->w_frame; return alt_tabpage()->tp_curwin->w_frame;
}
frp = win->w_frame; frp = win->w_frame;
if (frp->fr_parent != NULL && frp->fr_parent->fr_layout == FR_ROW)
b = p_spr; if (frp->fr_prev == NULL) {
else
b = p_sb;
if ((!b && frp->fr_next != NULL) || frp->fr_prev == NULL)
return frp->fr_next; return frp->fr_next;
return frp->fr_prev; }
if (frp->fr_next == NULL) {
return frp->fr_prev;
}
frame_T *target_fr = frp->fr_next;
frame_T *other_fr = frp->fr_prev;
if (p_spr || p_sb) {
target_fr = frp->fr_prev;
other_fr = frp->fr_next;
}
// If 'wfh' or 'wfw' is set for the target and not for the alternate
// window, reverse the selection.
if (frp->fr_parent != NULL && frp->fr_parent->fr_layout == FR_ROW) {
if (frame_fixed_width(target_fr) && !frame_fixed_width(other_fr)) {
target_fr = other_fr;
}
} else {
if (frame_fixed_height(target_fr) && !frame_fixed_height(other_fr)) {
target_fr = other_fr;
}
}
return target_fr;
} }
/* /*