]> granicus.if.org Git - vim/commitdiff
patch 8.2.2433: opening cmdline window gives error in BufLeave autocommand v8.2.2433
authorBram Moolenaar <Bram@vim.org>
Sat, 30 Jan 2021 20:40:03 +0000 (21:40 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 30 Jan 2021 20:40:03 +0000 (21:40 +0100)
Problem:    Opening cmdline window gives error in BufLeave autocommand.
Solution:   Reset cmdwin_type when triggering the autocommand.

src/ex_cmds.c
src/testdir/test_cmdline.vim
src/version.c

index 12219e7ba56a9e1e5f65f82a6008f1a96326b8c6..b678f6699cb4a60bb7b3bcf3e9123144c6ea65be 100644 (file)
@@ -2710,6 +2710,12 @@ do_ecmd(
         */
        if (buf != curbuf)
        {
+#ifdef FEAT_CMDWIN
+           int save_cmdwin_type = cmdwin_type;
+
+           // BufLeave applies to the old buffer.
+           cmdwin_type = 0;
+#endif
            /*
             * Be careful: The autocommands may delete any buffer and change
             * the current buffer.
@@ -2724,6 +2730,9 @@ do_ecmd(
                new_name = vim_strsave(buf->b_fname);
            set_bufref(&au_new_curbuf, buf);
            apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf);
+#ifdef FEAT_CMDWIN
+           cmdwin_type = save_cmdwin_type;
+#endif
            if (!bufref_valid(&au_new_curbuf))
            {
                // new buffer has been deleted
index c2bbcc6c0f00589d01efa0e6a296f8ef8ebbdc64..7f62dfe77487fc3307613e685c647f3b81e8f8b0 100644 (file)
@@ -1237,6 +1237,7 @@ func Test_cmdwin_autocmd()
 
   augroup CmdWin
     au!
+    autocmd BufLeave * if &buftype == '' | update | endif
     autocmd CmdwinEnter * startinsert
   augroup END
 
index dc20c3349cfc3c935c5c606dd74c188d4c258689..555a2f93785a26e186bccc8c8dc2472812d6e74d 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2433,
 /**/
     2432,
 /**/