]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0702: :windo and :tabdo create an extra window with 'winfixbuf' v9.2.0702
authorShivaPriyanShanmuga <pshanmugashiva@gmail.com>
Mon, 22 Jun 2026 19:07:09 +0000 (19:07 +0000)
committerChristian Brabandt <cb@256bit.org>
Mon, 22 Jun 2026 19:07:09 +0000 (19:07 +0000)
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 <pshanmugashiva@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/ex_cmds2.c
src/testdir/test_winfixbuf.vim
src/version.c

index afe9c4b58ad1022758a6bba7cc257dab6bbd1df4..f867c3c9c9c9112f38835f4b4b13dc626f71bb09 100644 (file)
@@ -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)
index 898443d9b52ea1da787fb3b8f12cc5e036d6f2c4..ba5cb979b7126f36d501086e50c9eaa65627a152 100644 (file)
@@ -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 \<C-w>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 \<C-w>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()
index db18e0cc9259721e361d7c58eff2c1f4ba9f3508..67a0fa650882ff7eeb2291a949429fa84bb400bd 100644 (file)
@@ -759,6 +759,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    702,
 /**/
     701,
 /**/