Skip to content

Commit 8c6951f

Browse files
committed
patch 8.2.2473: crash when leaving command line window triggers autocommand
Problem: Crash when leaving command line window triggers autocommand. (houyunsong) Solution: Make sure not to close the current window or buffer.
1 parent aad5f9d commit 8c6951f

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/ex_getln.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4403,12 +4403,12 @@ open_cmdwin(void)
44034403

44044404
// win_goto() may trigger an autocommand that already closes the
44054405
// cmdline window.
4406-
if (win_valid(wp))
4406+
if (win_valid(wp) && wp != curwin)
44074407
win_close(wp, TRUE);
44084408

44094409
// win_close() may have already wiped the buffer when 'bh' is
4410-
// set to 'wipe'
4411-
if (bufref_valid(&bufref))
4410+
// set to 'wipe', autocommands may have closed other windows
4411+
if (bufref_valid(&bufref) && bufref.br_buf != curbuf)
44124412
close_buffer(NULL, bufref.br_buf, DOBUF_WIPE, FALSE, FALSE);
44134413

44144414
// Restore window sizes.

src/testdir/test_autocmd.vim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2774,4 +2774,13 @@ func Test_autocmd_normal_mess()
27742774
augroup END
27752775
endfunc
27762776

2777+
func Test_autocmd_closing_cmdwin()
2778+
au BufWinLeave * nested q
2779+
call assert_fails("norm 7q?\n", 'E855:')
2780+
2781+
au! BufWinLeave
2782+
new
2783+
only
2784+
endfunc
2785+
27772786
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

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

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2473,
753755
/**/
754756
2472,
755757
/**/

0 commit comments

Comments
 (0)