Skip to content

Commit 46bdae0

Browse files
zeertzjqchrisbra
authored andcommitted
patch 9.0.1934: :bwipe fails after switching window from aucmd_win.
Problem: :bwipe fails after switching window from aucmd_win. Solution: Decrement b_nwindows after switching back to aucmd_win. closes: #13160 Signed-off-by: Christian Brabandt <[email protected]> Co-authored-by: zeertzjq <[email protected]>
1 parent edcba96 commit 46bdae0

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

src/autocmd.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,7 +1635,6 @@ aucmd_restbuf(
16351635
{
16361636
win_T *awp = aucmd_win[aco->use_aucmd_win_idx].auc_win;
16371637

1638-
--curbuf->b_nwindows;
16391638
// Find "awp", it can't be closed, but it may be in another tab
16401639
// page. Do not trigger autocommands here.
16411640
block_autocmds();
@@ -1656,8 +1655,8 @@ aucmd_restbuf(
16561655
}
16571656
}
16581657
win_found:
1658+
--curbuf->b_nwindows;
16591659
#ifdef FEAT_JOB_CHANNEL
1660-
;
16611660
int save_stop_insert_mode = stop_insert_mode;
16621661
// May need to stop Insert mode if we were in a prompt buffer.
16631662
leaving_window(curwin);

src/testdir/test_autocmd.vim

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3630,11 +3630,22 @@ func Test_closing_autocmd_window()
36303630
END
36313631
call v9.CheckScriptFailure(lines, 'E814:')
36323632
au! BufEnter
3633-
only!
36343633
bwipe Xa.txt
36353634
bwipe Xb.txt
36363635
endfunc
36373636

3637+
func Test_switch_window_in_autocmd_window()
3638+
edit Xa.txt
3639+
tabnew Xb.txt
3640+
autocmd BufEnter Xa.txt wincmd w
3641+
doautoall BufEnter
3642+
au! BufEnter
3643+
bwipe Xa.txt
3644+
call assert_false(bufexists('Xa.txt'))
3645+
bwipe Xb.txt
3646+
call assert_false(bufexists('Xb.txt'))
3647+
endfunc
3648+
36383649
func Test_bufwipeout_changes_window()
36393650
" This should not crash, but we don't have any expectations about what
36403651
" happens, changing window in BufWipeout has unpredictable results.

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,8 @@ static char *(features[]) =
699699

700700
static int included_patches[] =
701701
{ /* Add new patch number below this line */
702+
/**/
703+
1934,
702704
/**/
703705
1933,
704706
/**/

0 commit comments

Comments
 (0)