diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-04-07 14:08:29 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-04-07 14:08:29 +0100 |
commit | 6a06940f8ae7283999c83ccdf268540220573105 (patch) | |
tree | b40ba623a002b25c738cb9f513cc50cbc0fbc45e | |
parent | 6d4e725a3447af6f69305fdc9f1e1ff8d82e3863 (diff) |
patch 8.2.4706: buffer remains active with WinClosed and tabpagesv8.2.4706
Problem: Buffer remains active if a WinClosed event throws an exception
when there are multiple tabpages.
Solution: Ignore aborting() when closing the buffer. (closes #10101)
-rw-r--r-- | src/testdir/test_autocmd.vim | 17 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/window.c | 2 |
3 files changed, 20 insertions, 1 deletions
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim index 89023a1fb7..eb1fa046c5 100644 --- a/src/testdir/test_autocmd.vim +++ b/src/testdir/test_autocmd.vim @@ -365,6 +365,23 @@ func Test_WinClosed_throws() augroup! test-WinClosed endfunc +func Test_WinClosed_throws_with_tabs() + tabnew + 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/version.c b/src/version.c index 62623614a2..d0205d7e33 100644 --- a/src/version.c +++ b/src/version.c @@ -747,6 +747,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4706, +/**/ 4705, /**/ 4704, diff --git a/src/window.c b/src/window.c index 8ec4823a98..f763475892 100644 --- a/src/window.c +++ b/src/window.c @@ -2814,7 +2814,7 @@ win_close_othertab(win_T *win, int free_buf, tabpage_T *tp) if (win->w_buffer != NULL) // Close the link to the buffer. close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, - FALSE, FALSE); + FALSE, TRUE); // Careful: Autocommands may have closed the tab page or made it the // current tab page. |