mirror of
https://github.com/neovim/neovim.git
synced 2025-09-20 02:08:17 +00:00
vim-patch:8.2.1059: crash when using :tabonly in an autocommand
Problem: Crash when using :tabonly in an autocommand. (Yegappan Lakshmanan)
Solution: Do not allow the autocommand window to be closed.
cf8441704d
E813 error message does not mention 'popup' window
because Neovim floating window are regular windows, unlike Vim popups.
https://github.com/neovim/neovim/pull/14532#discussion_r631731829
This commit is contained in:
@@ -6520,6 +6520,12 @@ ex_win_close(
|
|||||||
int need_hide;
|
int need_hide;
|
||||||
buf_T *buf = win->w_buffer;
|
buf_T *buf = win->w_buffer;
|
||||||
|
|
||||||
|
// Never close the autocommand window.
|
||||||
|
if (win == aucmd_win) {
|
||||||
|
EMSG(_(e_autocmd_close));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
need_hide = (bufIsChanged(buf) && buf->b_nwindows <= 1);
|
need_hide = (bufIsChanged(buf) && buf->b_nwindows <= 1);
|
||||||
if (need_hide && !buf_hide(buf) && !forceit) {
|
if (need_hide && !buf_hide(buf) && !forceit) {
|
||||||
if ((p_confirm || cmdmod.confirm) && p_write) {
|
if ((p_confirm || cmdmod.confirm) && p_write) {
|
||||||
|
@@ -987,6 +987,8 @@ EXTERN char_u e_dirnotf[] INIT(= N_(
|
|||||||
"E919: Directory not found in '%s': \"%s\""));
|
"E919: Directory not found in '%s': \"%s\""));
|
||||||
EXTERN char_u e_au_recursive[] INIT(= N_(
|
EXTERN char_u e_au_recursive[] INIT(= N_(
|
||||||
"E952: Autocommand caused recursive behavior"));
|
"E952: Autocommand caused recursive behavior"));
|
||||||
|
EXTERN char_u e_autocmd_close[] INIT(= N_(
|
||||||
|
"E813: Cannot close autocmd window"));
|
||||||
EXTERN char_u e_unsupportedoption[] INIT(= N_("E519: Option not supported"));
|
EXTERN char_u e_unsupportedoption[] INIT(= N_("E519: Option not supported"));
|
||||||
EXTERN char_u e_fnametoolong[] INIT(= N_("E856: Filename too long"));
|
EXTERN char_u e_fnametoolong[] INIT(= N_("E856: Filename too long"));
|
||||||
EXTERN char_u e_float_as_string[] INIT(= N_("E806: using Float as a String"));
|
EXTERN char_u e_float_as_string[] INIT(= N_("E806: using Float as a String"));
|
||||||
|
@@ -1949,6 +1949,26 @@ func Test_autocmd_window()
|
|||||||
%bw!
|
%bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for trying to close the tab that has the temporary window for exeucing
|
||||||
|
" an autocmd.
|
||||||
|
func Test_close_autocmd_tab()
|
||||||
|
edit one.txt
|
||||||
|
tabnew two.txt
|
||||||
|
augroup aucmd_win_test
|
||||||
|
au!
|
||||||
|
au BufEnter * if expand('<afile>') == 'one.txt' | tabfirst | tabonly | endif
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
call assert_fails('doautoall BufEnter', 'E813:')
|
||||||
|
|
||||||
|
tabonly
|
||||||
|
augroup aucmd_win_test
|
||||||
|
au!
|
||||||
|
augroup END
|
||||||
|
augroup! aucmd_win_test
|
||||||
|
%bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_autocmd_closes_window()
|
func Test_autocmd_closes_window()
|
||||||
au BufNew,BufWinLeave * e %e
|
au BufNew,BufWinLeave * e %e
|
||||||
file yyy
|
file yyy
|
||||||
|
@@ -2286,7 +2286,7 @@ int win_close(win_T *win, bool free_buf)
|
|||||||
return FAIL; // window is already being closed
|
return FAIL; // window is already being closed
|
||||||
}
|
}
|
||||||
if (win == aucmd_win) {
|
if (win == aucmd_win) {
|
||||||
EMSG(_("E813: Cannot close autocmd window"));
|
EMSG(_(e_autocmd_close));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
if ((firstwin == aucmd_win || lastwin == aucmd_win) && one_window()) {
|
if ((firstwin == aucmd_win || lastwin == aucmd_win) && one_window()) {
|
||||||
|
Reference in New Issue
Block a user