Skip to content

Commit b63f3ca

Browse files
committed
patch 8.2.2433: opening cmdline window gives error in BufLeave autocommand
Problem: Opening cmdline window gives error in BufLeave autocommand. Solution: Reset cmdwin_type when triggering the autocommand.
1 parent 76ab544 commit b63f3ca

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

src/ex_cmds.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2710,6 +2710,12 @@ do_ecmd(
27102710
*/
27112711
if (buf != curbuf)
27122712
{
2713+
#ifdef FEAT_CMDWIN
2714+
int save_cmdwin_type = cmdwin_type;
2715+
2716+
// BufLeave applies to the old buffer.
2717+
cmdwin_type = 0;
2718+
#endif
27132719
/*
27142720
* Be careful: The autocommands may delete any buffer and change
27152721
* the current buffer.
@@ -2724,6 +2730,9 @@ do_ecmd(
27242730
new_name = vim_strsave(buf->b_fname);
27252731
set_bufref(&au_new_curbuf, buf);
27262732
apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf);
2733+
#ifdef FEAT_CMDWIN
2734+
cmdwin_type = save_cmdwin_type;
2735+
#endif
27272736
if (!bufref_valid(&au_new_curbuf))
27282737
{
27292738
// new buffer has been deleted

src/testdir/test_cmdline.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,6 +1237,7 @@ func Test_cmdwin_autocmd()
12371237

12381238
augroup CmdWin
12391239
au!
1240+
autocmd BufLeave * if &buftype == '' | update | endif
12401241
autocmd CmdwinEnter * startinsert
12411242
augroup END
12421243

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+
2433,
753755
/**/
754756
2432,
755757
/**/

0 commit comments

Comments
 (0)