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

96cc4aef3d

Most of the patch was already ported. This includes the remaining part.

Co-authored-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
This commit is contained in:
zeertzjq
2026-01-14 15:43:19 +08:00
parent d6e5286d2c
commit 4544cec168
2 changed files with 4 additions and 3 deletions

View File

@@ -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) {

View File

@@ -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