diff options
author | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-08-21 22:18:15 -0400 |
---|---|---|
committer | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-08-21 22:36:31 -0400 |
commit | 54e6ef73f058f3e3a340addd6354cf70e2fd11b7 (patch) | |
tree | d5d8f0e2dd316c47f3b5cd66f56ebf4aa4efe432 /src/nvim/window.c | |
parent | b5fc21dbf05874ef7901a5e66f39612c46a698e3 (diff) | |
download | rneovim-54e6ef73f058f3e3a340addd6354cf70e2fd11b7.tar.gz rneovim-54e6ef73f058f3e3a340addd6354cf70e2fd11b7.tar.bz2 rneovim-54e6ef73f058f3e3a340addd6354cf70e2fd11b7.zip |
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)
https://github.com/vim/vim/commit/c136af29c0b1939076fbae7d36afd90dce740315
Diffstat (limited to 'src/nvim/window.c')
-rw-r--r-- | src/nvim/window.c | 54 |
1 files changed, 37 insertions, 17 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c index 89ab2c2b9c..3f66568b58 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -2337,14 +2337,14 @@ winframe_remove ( return wp; } -/* - * Find out which frame is going to get the freed up space when "win" is - * closed. - * if 'splitbelow'/'splitleft' the space goes to the window above/left. - * if 'nosplitbelow'/'nosplitleft' the space goes to the window below/right. - * This makes opening a window and closing it immediately keep the same window - * layout. - */ +// Return a pointer to the frame that will receive the empty screen space that +// is left over after "win" is closed. +// +// If 'splitbelow' or 'splitright' is set, the space goes above or to the left +// by default. Otherwise, the free space goes below or to the right. The +// result is that opening a window and then immediately closing it will +// preserve the initial window layout. The 'wfh' and 'wfw' settings are +// respected when possible. static frame_T * win_altframe ( win_T *win, @@ -2352,20 +2352,40 @@ win_altframe ( ) { frame_T *frp; - int b; - if (tp == NULL ? ONE_WINDOW : tp->tp_firstwin == tp->tp_lastwin) - /* Last window in this tab page, will go to next tab page. */ + if (tp == NULL ? ONE_WINDOW : tp->tp_firstwin == tp->tp_lastwin) { return alt_tabpage()->tp_curwin->w_frame; + } frp = win->w_frame; - if (frp->fr_parent != NULL && frp->fr_parent->fr_layout == FR_ROW) - b = p_spr; - else - b = p_sb; - if ((!b && frp->fr_next != NULL) || frp->fr_prev == NULL) + + if (frp->fr_prev == NULL) { 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; } /* |