patch 9.1.1513: resizing Vim window causes unexpected internal window width

Commit: 
https://github.com/vim/vim/commit/88be7a6c68c9d288914e6973564a86918055b4bd
Author: Hirohito Higashi <h.east....@gmail.com>
Date:   Sun Jul 6 10:34:48 2025 +0200

    patch 9.1.1513: resizing Vim window causes unexpected internal window width
    
    Problem:  resizing Vim window causes unexpected internal window width
              (chdiza, after v9.1.1465)
    Solution: move the column calculation around (Hirohito Higashi)
    
    fixes: #17657
    fixes: #17595
    closes: #17668
    
    Signed-off-by: Hirohito Higashi <h.east....@gmail.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/term.c b/src/term.c
index 720c8a0c6..c892c6d06 100644
--- a/src/term.c
+++ b/src/term.c
@@ -3619,6 +3619,13 @@ win_new_shellsize(void)
     if (old_Rows != Rows || old_Columns != COLUMNS_WITHOUT_TPL()
            || old_coloff != TPL_LCOL())
        ui_new_shellsize();
+    if (old_Columns != COLUMNS_WITHOUT_TPL() || old_coloff != TPL_LCOL())
+    {
+       old_Columns = COLUMNS_WITHOUT_TPL();
+       old_coloff = TPL_LCOL();
+
+       shell_new_columns();
+    }
     if (old_Rows != Rows)
     {
        // If 'window' uses the whole screen, keep it using that.
@@ -3629,13 +3636,6 @@ win_new_shellsize(void)
        old_Rows = Rows;
        shell_new_rows();       // update window sizes
     }
-    if (old_Columns != COLUMNS_WITHOUT_TPL() || old_coloff != TPL_LCOL())
-    {
-       old_Columns = COLUMNS_WITHOUT_TPL();
-       old_coloff = TPL_LCOL();
-
-       shell_new_columns();
-    }
 }
 
 /*
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index 3dc496026..4d001c216 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -5479,4 +5479,29 @@ func Test_eventignore_subtract()
   %bw!
 endfunc
 
+func Test_VimResized_and_window_width_not_equalized()
+  CheckRunVimInTerminal
+
+  let lines =<< trim END
+    let g:vim_resized = 0
+    autocmd VimResized * let g:vim_resized = 1
+    10vsplit
+  END
+  call writefile(lines, 'XTest_VimResize', 'D')
+  let buf = RunVimInTerminal('-S XTest_VimResize', {'rows': 10, 'cols': 30})
+
+  " redraw now to avoid a redraw after the :echo command
+  call term_sendkeys(buf, ":redraw!\<CR>")
+  call TermWait(buf)
+
+  call term_sendkeys(buf, ":set columns=40\<CR>")
+  call term_sendkeys(buf, ":echo 'VimResized:' g:vim_resized\<CR>")
+  call WaitForAssert({-> assert_match('^VimResized: 1$', term_getline(buf, 
10))}, 1000)
+  call term_sendkeys(buf, ":let window_width = 
getwininfo(win_getid())[0].width\<CR>")
+  call term_sendkeys(buf, ":echo 'window_width:' window_width\<CR>")
+  call WaitForAssert({-> assert_match('^window_width: 10$', term_getline(buf, 
10))}, 1000)
+
+  call StopVimInTerminal(buf)
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index f06c222f4..fdf1eb300 100644
--- a/src/version.c
+++ b/src/version.c
@@ -719,6 +719,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1513,
 /**/
     1512,
 /**/
diff --git a/src/window.c b/src/window.c
index 3d2528fa6..484fdf8e1 100644
--- a/src/window.c
+++ b/src/window.c
@@ -3461,9 +3461,9 @@ win_close_othertab(win_T *win, int free_buf, tabpage_T 
*tp)
        }
        free_tp = TRUE;
        redraw_tabline = TRUE;
+       shell_new_columns();
        if (h != tabline_height())
            shell_new_rows();
-       shell_new_columns();
     }
 
     // Free the memory used for the window.
@@ -6160,6 +6160,8 @@ win_free_lsize(win_T *wp)
 /*
  * Called from win_new_shellsize() after Rows changed.
  * This only does the current tab page, others must be done when made active.
+ * Note: When called together with shell_new_columns(), call 
shell_new_columns()
+ * first to avoid this function updating firstwin->w_wincol first.
  */
     void
 shell_new_rows(void)
@@ -6204,8 +6206,10 @@ shell_new_columns(void)
     if (firstwin == NULL)      // not initialized yet
        return;
 
+#if defined(FEAT_TABPANEL)
     int save_wincol = firstwin->w_wincol;
     int save_fr_width = topframe->fr_width;
+#endif
     int w = COLUMNS_WITHOUT_TPL();
 
     // First try setting the widths of windows with 'winfixwidth'.  If that
@@ -6216,9 +6220,13 @@ shell_new_columns(void)
 
     win_comp_pos();            // recompute w_winrow and w_wincol
 
-    if (p_ea && (firstwin->w_wincol != save_wincol
-               || topframe->fr_width != save_fr_width))
+#if defined(FEAT_TABPANEL)
+    if (p_ea && firstwin->w_wincol + topframe->fr_width
+           == save_wincol + save_fr_width &&
+           (firstwin->w_wincol != save_wincol ||
+            topframe->fr_width != save_fr_width))
        win_equal(curwin, FALSE, 0);
+#endif
     if (!skip_win_fix_scroll)
        win_fix_scroll(TRUE);
 

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1uYKzf-006N4c-Uc%40256bit.org.

Raspunde prin e-mail lui