diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2021-05-11 21:20:32 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2021-05-13 20:46:00 -0400 |
commit | f54a938271a4006a05638956a46e0bbe114eedf7 (patch) | |
tree | 1fbcf0320d046fc4622ac2fe8e407e6f34c65d70 /src | |
parent | 73392909006de74e628323cde915b107244a247b (diff) | |
download | rneovim-f54a938271a4006a05638956a46e0bbe114eedf7.tar.gz rneovim-f54a938271a4006a05638956a46e0bbe114eedf7.tar.bz2 rneovim-f54a938271a4006a05638956a46e0bbe114eedf7.zip |
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.
https://github.com/vim/vim/commit/cf8441704d6e517bda1899f4afa82c6b4eecbaec
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
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/ex_docmd.c | 6 | ||||
-rw-r--r-- | src/nvim/globals.h | 2 | ||||
-rw-r--r-- | src/nvim/testdir/test_autocmd.vim | 20 | ||||
-rw-r--r-- | src/nvim/window.c | 2 |
4 files changed, 29 insertions, 1 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 87e482620c..1b44b92aa2 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -6520,6 +6520,12 @@ ex_win_close( int need_hide; 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); if (need_hide && !buf_hide(buf) && !forceit) { if ((p_confirm || cmdmod.confirm) && p_write) { diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 624b7c93f3..0ce2b586e3 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -987,6 +987,8 @@ EXTERN char_u e_dirnotf[] INIT(= N_( "E919: Directory not found in '%s': \"%s\"")); EXTERN char_u e_au_recursive[] INIT(= N_( "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_fnametoolong[] INIT(= N_("E856: Filename too long")); EXTERN char_u e_float_as_string[] INIT(= N_("E806: using Float as a String")); diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 5611560b1b..fb3aa2b3b0 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -1949,6 +1949,26 @@ func Test_autocmd_window() %bw! 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() au BufNew,BufWinLeave * e %e file yyy diff --git a/src/nvim/window.c b/src/nvim/window.c index d4d00c0a71..30ce2ba9f4 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -2286,7 +2286,7 @@ int win_close(win_T *win, bool free_buf) return FAIL; // window is already being closed } if (win == aucmd_win) { - EMSG(_("E813: Cannot close autocmd window")); + EMSG(_(e_autocmd_close)); return FAIL; } if ((firstwin == aucmd_win || lastwin == aucmd_win) && one_window()) { |