Fixes this bug / feature request: When doing ":sp" in a big window below a small window, 'equalalways' causes the small window to become bigger. Make it so that after ":sp" only the split windows can become bigger (perhaps by checking if, after the split, all other windows are smaller than the two split windows). Solution: Move the 'equalalways' check down after the size of the new window has been calculated and implement the check suggested by the bug report. Equivalent behaviour is implemented for vertical split. Created by Martin Toft during Google Summer of Code 2007. Index: runtime/doc/options.txt =================================================================== RCS file: /cvsroot/vim/vim7/runtime/doc/options.txt,v retrieving revision 1.139 diff -c -r1.139 options.txt *** runtime/doc/options.txt 12 May 2007 14:27:04 -0000 1.139 --- runtime/doc/options.txt 6 Aug 2007 22:47:04 -0000 *************** *** 2415,2422 **** When mixing vertically and horizontally split windows, a minimal size is computed and some windows may be larger if there is room. The 'eadirection' option tells in which direction the size is affected. ! Changing the height of a window can be avoided by setting ! 'winfixheight'. *'equalprg'* *'ep'* 'equalprg' 'ep' string (default "") --- 2415,2422 ---- When mixing vertically and horizontally split windows, a minimal size is computed and some windows may be larger if there is room. The 'eadirection' option tells in which direction the size is affected. ! Changing the height and width of a window can be avoided by setting ! 'winfixheight' and 'winfixwidth', respectively. *'equalprg'* *'ep'* 'equalprg' 'ep' string (default "") Index: runtime/doc/windows.txt =================================================================== RCS file: /cvsroot/vim/vim7/runtime/doc/windows.txt,v retrieving revision 1.28 diff -c -r1.28 windows.txt *** runtime/doc/windows.txt 12 May 2007 14:42:48 -0000 1.28 --- runtime/doc/windows.txt 6 Aug 2007 22:47:05 -0000 *************** *** 132,138 **** the same file. Make new window N high (default is to use half the height of the current window). Reduces the current window height to create room (and others, if the 'equalalways' option ! is set and 'eadirection' isn't "hor"). Note: CTRL-S does not work on all terminals and might block further input, use CTRL-Q to get going again. Also see |++opt| and |+cmd|. --- 132,139 ---- the same file. Make new window N high (default is to use half the height of the current window). Reduces the current window height to create room (and others, if the 'equalalways' option ! is set, 'eadirection' isn't "hor", and one of them is higher ! than the current or the new window). Note: CTRL-S does not work on all terminals and might block further input, use CTRL-Q to get going again. Also see |++opt| and |+cmd|. *************** *** 140,148 **** CTRL-W CTRL-V *CTRL-W_CTRL-V* CTRL-W v *CTRL-W_v* :[N]vs[plit] [++opt] [+cmd] [file] *:vs* *:vsplit* ! Like |:split|, but split vertically. If 'equalalways' is set ! and 'eadirection' isn't "ver" the windows will be spread out ! horizontally, unless a width was specified. Note: In other places CTRL-Q does the same as CTRL-V, but here it doesn't! --- 141,153 ---- CTRL-W CTRL-V *CTRL-W_CTRL-V* CTRL-W v *CTRL-W_v* :[N]vs[plit] [++opt] [+cmd] [file] *:vs* *:vsplit* ! Like |:split|, but split vertically. The windows will be ! spread out horizontally if ! 1. a width was not specified, ! 2. 'equalalways' is set, ! 3. 'eadirection' isn't "ver", and ! 4. one of the other windows are wider than the current or new ! window. Note: In other places CTRL-Q does the same as CTRL-V, but here it doesn't! Index: src/window.c =================================================================== RCS file: /cvsroot/vim/vim7/src/window.c,v retrieving revision 1.63 diff -c -r1.63 window.c *** src/window.c 5 Aug 2007 16:49:21 -0000 1.63 --- src/window.c 6 Aug 2007 22:47:07 -0000 *************** *** 733,739 **** if (flags & WSP_VERT) { layout = FR_ROW; - do_equal = (p_ea && new_size == 0 && *p_ead != 'v'); /* * Check if we are able to split the current window and compute its --- 733,738 ---- *************** *** 770,785 **** * instead, if possible. */ if (oldwin->w_p_wfw) win_setwidth_win(oldwin->w_width + new_size, oldwin); } else #endif { layout = FR_COL; - do_equal = (p_ea && new_size == 0 - #ifdef FEAT_VERTSPLIT - && *p_ead != 'h' - #endif - ); /* * Check if we are able to split the current window and compute its --- 769,799 ---- * instead, if possible. */ if (oldwin->w_p_wfw) win_setwidth_win(oldwin->w_width + new_size, oldwin); + + /* Only make all windows the same width if one of them (except oldwin) + * is wider than one of the split windows. */ + if (!do_equal && p_ea && size == 0 && *p_ead != 'v' + && oldwin->w_frame->fr_parent != NULL) + { + frp = oldwin->w_frame->fr_parent->fr_child; + while (frp != NULL) + { + if (frp->fr_win != oldwin && frp->fr_win != NULL + && (frp->fr_win->w_width > new_size + || frp->fr_win->w_width > oldwin->w_width + - new_size - STATUS_HEIGHT)) + { + do_equal = TRUE; + break; + } + frp = frp->fr_next; + } + } } else #endif { layout = FR_COL; /* * Check if we are able to split the current window and compute its *************** *** 832,837 **** --- 846,874 ---- if (need_status) oldwin_height -= STATUS_HEIGHT; } + + /* Only make all windows the same height if one of them (except oldwin) + * is higher than one of the split windows. */ + if (!do_equal && p_ea && size == 0 + #ifdef FEAT_VERTSPLIT + && *p_ead != 'h' + #endif + && oldwin->w_frame->fr_parent != NULL) + { + frp = oldwin->w_frame->fr_parent->fr_child; + while (frp != NULL) + { + if (frp->fr_win != oldwin && frp->fr_win != NULL + && (frp->fr_win->w_height > new_size + || frp->fr_win->w_height > oldwin_height - new_size + - STATUS_HEIGHT)) + { + do_equal = TRUE; + break; + } + frp = frp->fr_next; + } + } } /*