commit 4544cec168e0197ba694177e163a36b49d013c37
parent d6e5286d2c533d97d4efe4644559b81702d3caba
Author: zeertzjq <zeertzjq@outlook.com>
Date: Wed, 14 Jan 2026 15:43:19 +0800
vim-patch:9.1.0117: Stop split-moving from firing WinNew and WinNewPre autocommands
Problem: win_splitmove fires WinNewPre and possibly WinNew when moving
windows, even though no new windows are created.
Solution: don't fire WinNew and WinNewPre when inserting an existing
window, even if it isn't the current window. Improve the
accuracy of related documentation. (Sean Dewar)
related: vim/vim#14038
https://github.com/vim/vim/commit/96cc4aef3d47d0fd70e68908af3d48a0dce8ea70
Most of the patch was already ported. This includes the remaining part.
Co-authored-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Diffstat:
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/nvim/window.c b/src/nvim/window.c
@@ -1127,7 +1127,9 @@ win_T *win_split_ins(int size, int flags, win_T *new_wp, int dir, frame_T *to_fl
return NULL;
}
- trigger_winnewpre();
+ if (new_wp == NULL) {
+ trigger_winnewpre();
+ }
win_T *oldwin;
if (flags & WSP_TOP) {
diff --git a/test/old/testdir/test_window_cmd.vim b/test/old/testdir/test_window_cmd.vim
@@ -1043,8 +1043,7 @@ func Test_win_splitmove()
let s:triggered = []
augroup WinSplitMove
au!
- " Nvim: WinNewPre not ported yet. Also needs full port of v9.1.0117 to pass.
- " au WinNewPre * let s:triggered += ['WinNewPre']
+ au WinNewPre * let s:triggered += ['WinNewPre']
au WinNew * let s:triggered += ['WinNew', win_getid()]
au WinClosed * let s:triggered += ['WinClosed', str2nr(expand('<afile>'))]
augroup END