diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-04-08 07:57:50 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-04-08 08:54:07 +0800 |
commit | b7bc931f631febeeffee528cc3b5667cfbf60a90 (patch) | |
tree | 5fc1a39ed14acd0120b693f54b42f9058da718f5 | |
parent | 44b59d1a696b35d2520dbea2de3aab01e740a7ca (diff) | |
download | rneovim-b7bc931f631febeeffee528cc3b5667cfbf60a90.tar.gz rneovim-b7bc931f631febeeffee528cc3b5667cfbf60a90.tar.bz2 rneovim-b7bc931f631febeeffee528cc3b5667cfbf60a90.zip |
vim-patch:8.2.4700: buffer remains active if WinClosed event throws an exception
Problem: Buffer remains active if a WinClosed event throws an exception.
Solution: Ignore aborting() when closing the buffer. (closes vim/vim#10097)
https://github.com/vim/vim/commit/c947b9ae419114ebfef9725814ea41a466fcf879
-rw-r--r-- | src/nvim/testdir/test_autocmd.vim | 17 | ||||
-rw-r--r-- | src/nvim/window.c | 2 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 76c69ad10b..ce2ca1322e 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -299,6 +299,23 @@ func Test_WinClosed() unlet g:triggered endfunc +func Test_WinClosed_throws() + vnew + let bnr = bufnr() + call assert_equal(1, bufloaded(bnr)) + augroup test-WinClosed + autocmd WinClosed * throw 'foo' + augroup END + try + close + catch /.*/ + endtry + call assert_equal(0, bufloaded(bnr)) + + autocmd! test-WinClosed + augroup! test-WinClosed +endfunc + func s:AddAnAutocmd() augroup vimBarTest au BufReadCmd * echo 'hello' diff --git a/src/nvim/window.c b/src/nvim/window.c index 20f2447bbe..21350f1a38 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -2563,7 +2563,7 @@ static void win_close_buffer(win_T *win, bool free_buf, bool abort_if_last) bufref_T bufref; set_bufref(&bufref, curbuf); win->w_closing = true; - close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, abort_if_last, false); + close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, abort_if_last, true); if (win_valid_any_tab(win)) { win->w_closing = false; } |