]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0785: WinResized not triggered when the whole Vim is resized v9.2.0785
authorHirohito Higashi <h.east.727@gmail.com>
Fri, 17 Jul 2026 15:03:10 +0000 (15:03 +0000)
committerChristian Brabandt <cb@256bit.org>
Fri, 17 Jul 2026 15:03:10 +0000 (15:03 +0000)
Problem:  When the whole Vim (terminal or GUI) is resized, VimResized fires
          right away but WinResized does not: it only triggers on the next
          typed command, even though the windows already changed size
          (Mao-Yining).
Solution: Trigger the WinResized (and WinScrolled) check right after firing
          VimResized on a shell resize, so window size changes are reported
          immediately instead of waiting for the next command
          (Hirohito Higashi).

fixes:  #20774
closes: #20775

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/screen.c
src/testdir/test_autocmd.vim
src/version.c

index de2def9e0fb906bf574e5a33bbddd3ad35a0c5a1..7d75af0226e1a25be9ce0c389230d455d8ed9e96 100644 (file)
@@ -3531,6 +3531,9 @@ give_up:
     if (starting == 0 && ++retry_count <= 3)
     {
        apply_autocmds(EVENT_VIMRESIZED, NULL, NULL, FALSE, curbuf);
+       // A shell resize also changes window sizes; trigger WinResized (and
+       // WinScrolled) now instead of waiting for the next command.
+       may_trigger_win_scrolled_resized();
        // In rare cases, autocommands may have altered Rows or Columns,
        // jump back to check if we need to allocate the screen again.
        goto retry;
index b2a3dea149d0102aae76e387b290e68dfbef1d25..7e36eec53e7b005b3dd65739b5f1a308e581ee49 100644 (file)
@@ -5872,6 +5872,27 @@ func Test_VimResized_and_window_width_not_equalized()
   call StopVimInTerminal(buf)
 endfunc
 
+func Test_WinResized_on_shell_resize()
+  CheckRunVimInTerminal
+
+  " A shell (terminal/GUI) resize changes window sizes, so WinResized must
+  " trigger from the resize alone, not only on the next typed command.
+  let lines =<< trim END
+    autocmd WinResized * call writefile(['x'], 'XwinResized', 'a')
+  END
+  call writefile(lines, 'XTest_WinResized_shell', 'D')
+  let buf = RunVimInTerminal('-S XTest_WinResized_shell', {'rows': 10, 'cols': 30})
+  call TermWait(buf)
+  call delete('XwinResized')
+
+  " Resize the terminal (SIGWINCH); do not send any key to the inner Vim.
+  call term_setsize(buf, 15, 40)
+  call WaitForAssert({-> assert_true(filereadable('XwinResized'))})
+
+  call StopVimInTerminal(buf)
+  call delete('XwinResized')
+endfunc
+
 func Test_win_tabclose_autocmd()
 
   defer CleanUpTestAuGroup()
index 5d0425b3f7d1c63ac3b21c66a7f391c80d246cea..17f67c4328f445d29ca9374fcdc2ea85c00fdebc 100644 (file)
@@ -759,6 +759,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    785,
 /**/
     784,
 /**/