patch 9.2.0785: WinResized not triggered when the whole Vim is resized
Commit:
https://github.com/vim/vim/commit/dc8a7195e5b58dc0050b340aa7e7844ca5901200
Author: Hirohito Higashi <
h.eas...@gmail.com>
Date: Fri Jul 17 15:03:10 2026 +0000
patch 9.2.0785: WinResized not triggered when the whole Vim is resized
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) <
nor...@anthropic.com>
Signed-off-by: Hirohito Higashi <
h.eas...@gmail.com>
Signed-off-by: Christian Brabandt <
c...@256bit.org>
diff --git a/src/screen.c b/src/screen.c
index de2def9e0..7d75af022 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -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;
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index b2a3dea14..7e36eec53 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -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()
diff --git a/src/version.c b/src/version.c
index 5d0425b3f..17f67c432 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 */
+/**/
+ 785,
/**/
784,
/**/