From: ShivaPriyanShanmuga Date: Mon, 22 Jun 2026 19:07:09 +0000 (+0000) Subject: patch 9.2.0702: :windo and :tabdo create an extra window with 'winfixbuf' X-Git-Tag: v9.2.0702^0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5767d80b3794b17e5b61afec966fdeb7c0c4506f;p=thirdparty%2Fvim.git patch 9.2.0702: :windo and :tabdo create an extra window with 'winfixbuf' Problem: With 'winfixbuf' set in the current window, :windo and :tabdo create an extra split window, even though they only visit existing windows/tabpages and don't change the current window's buffer (Collin Kennedy) Solution: Skip the 'winfixbuf' escape in ex_listdo() for :windo and :tabdo (ShivaPriyanShanmuga) fixes: #14301 closes: #20600 Signed-off-by: ShivaPriyanShanmuga Signed-off-by: Christian Brabandt --- diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index afe9c4b58a..f867c3c9c9 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -478,7 +478,11 @@ ex_listdo(exarg_T *eap) buf_T *buf = curbuf; int next_fnum = 0; - if (curwin->w_p_wfb) + // ":windo" and ":tabdo" only visit existing windows/tabpages, they don't + // change the current window's buffer, so they can't escape a 'winfixbuf' + // window (which would create a split). + if (curwin->w_p_wfb && eap->cmdidx != CMD_windo && + eap->cmdidx != CMD_tabdo) { if ((eap->cmdidx == CMD_ldo || eap->cmdidx == CMD_lfdo) && !eap->forceit) diff --git a/src/testdir/test_winfixbuf.vim b/src/testdir/test_winfixbuf.vim index 898443d9b5..ba5cb979b7 100644 --- a/src/testdir/test_winfixbuf.vim +++ b/src/testdir/test_winfixbuf.vim @@ -2857,36 +2857,34 @@ func Test_tNext() set tags& endfunc -" Call :tabdo and choose the next available 'nowinfixbuf' window. -func Test_tabdo_choose_available_window() +" Call :tabdo and stay in the 'winfixbuf' window: it only visits tabpages and +" doesn't change the current buffer, so it must not switch to another window +" even when a 'nowinfixbuf' window is available. +func Test_tabdo_stay_in_winfixbuf_window() call s:reset_all_buffers() let [l:first, _] = s:make_args_list() - " Make a split window that is 'nowinfixbuf' but make it the second-to-last - " window so that :tabdo will first try the 'winfixbuf' window, pass over it, - " and prefer the other 'nowinfixbuf' window, instead. - " " +-------------------+ " | 'nowinfixbuf' | " +-------------------+ " | 'winfixbuf' | <-- Cursor is here " +-------------------+ split - let l:nowinfixbuf_window = win_getid() " Move to the 'winfixbuf' window now exe "normal \j" let l:winfixbuf_window = win_getid() let l:expected_windows = s:get_windows_count() tabdo echo '' - call assert_equal(l:nowinfixbuf_window, win_getid()) + call assert_equal(l:winfixbuf_window, win_getid()) call assert_equal(l:first, bufnr()) call assert_equal(l:expected_windows, s:get_windows_count()) endfunc -" Call :tabdo and create a new split window if all available windows are 'winfixbuf'. -func Test_tabdo_make_new_window() +" Call :tabdo and do not create a new window even when the only window is +" 'winfixbuf'. +func Test_tabdo_no_new_window() call s:reset_all_buffers() let [l:first, _] = s:make_buffers_list() @@ -2896,11 +2894,9 @@ func Test_tabdo_make_new_window() let l:current_windows = s:get_windows_count() tabdo echo '' - call assert_notequal(l:current, win_getid()) + call assert_equal(l:current, win_getid()) call assert_equal(l:first, bufnr()) - exe "normal \j" - call assert_equal(l:first, bufnr()) - call assert_equal(l:current_windows + 1, s:get_windows_count()) + call assert_equal(l:current_windows, s:get_windows_count()) endfunc " Fail :tag but :tag! is allowed @@ -3214,6 +3210,23 @@ func Test_windo() call assert_equal(l:current_window, win_getid()) endfunc +" Call :windo and do not create a new window even when the only window is +" 'winfixbuf'. +func Test_windo_no_new_window() + call s:reset_all_buffers() + + let [l:first, _] = s:make_buffers_list() + exe $"buffer! {l:first}" + + let l:current = win_getid() + let l:current_windows = s:get_windows_count() + + windo echo '' + call assert_equal(l:current, win_getid()) + call assert_equal(l:first, bufnr()) + call assert_equal(l:current_windows, s:get_windows_count()) +endfunc + " Fail :wnext but :wnext! is allowed func Test_wnext() call s:reset_all_buffers() diff --git a/src/version.c b/src/version.c index db18e0cc92..67a0fa6508 100644 --- a/src/version.c +++ b/src/version.c @@ -759,6 +759,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 702, /**/ 701, /**/