comparison src/ex_cmds.c @ 23784:34a95c4bd647 v8.2.2433

patch 8.2.2433: opening cmdline window gives error in BufLeave autocommand Commit: https://github.com/vim/vim/commit/b63f3ca66db20f7b135aae706d36be538f91f8cc Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jan 30 21:40:03 2021 +0100 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.
author Bram Moolenaar <Bram@vim.org>
date Sat, 30 Jan 2021 21:45:03 +0100
parents 1a53383f08e5
children 7517eb94239b
comparison
equal deleted inserted replaced
23783:de88fbcda74a 23784:34a95c4bd647
2708 * If the current buffer was empty and has no file name, curbuf 2708 * If the current buffer was empty and has no file name, curbuf
2709 * is returned by buflist_new(), nothing to do here. 2709 * is returned by buflist_new(), nothing to do here.
2710 */ 2710 */
2711 if (buf != curbuf) 2711 if (buf != curbuf)
2712 { 2712 {
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
2713 /* 2719 /*
2714 * Be careful: The autocommands may delete any buffer and change 2720 * Be careful: The autocommands may delete any buffer and change
2715 * the current buffer. 2721 * the current buffer.
2716 * - If the buffer we are going to edit is deleted, give up. 2722 * - If the buffer we are going to edit is deleted, give up.
2717 * - If the current buffer is deleted, prefer to load the new 2723 * - If the current buffer is deleted, prefer to load the new
2722 */ 2728 */
2723 if (buf->b_fname != NULL) 2729 if (buf->b_fname != NULL)
2724 new_name = vim_strsave(buf->b_fname); 2730 new_name = vim_strsave(buf->b_fname);
2725 set_bufref(&au_new_curbuf, buf); 2731 set_bufref(&au_new_curbuf, buf);
2726 apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf); 2732 apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf);
2733 #ifdef FEAT_CMDWIN
2734 cmdwin_type = save_cmdwin_type;
2735 #endif
2727 if (!bufref_valid(&au_new_curbuf)) 2736 if (!bufref_valid(&au_new_curbuf))
2728 { 2737 {
2729 // new buffer has been deleted 2738 // new buffer has been deleted
2730 delbuf_msg(new_name); // frees new_name 2739 delbuf_msg(new_name); // frees new_name
2731 goto theend; 2740 goto theend;