From: Hirohito Higashi Date: Fri, 17 Jul 2026 15:03:10 +0000 (+0000) Subject: patch 9.2.0785: WinResized not triggered when the whole Vim is resized X-Git-Tag: v9.2.0785^0 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dc8a7195e5b58dc0050b340aa7e7844ca5901200;p=thirdparty%2Fvim.git 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) Signed-off-by: Hirohito Higashi Signed-off-by: Christian Brabandt --- diff --git a/src/screen.c b/src/screen.c index de2def9e0f..7d75af0226 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 b2a3dea149..7e36eec53e 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 5d0425b3f7..17f67c4328 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, /**/