Skip to content

Commit

Permalink
patch 8.2.4706: buffer remains active with WinClosed and tabpages
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
zeertzjq authored and brammool committed Apr 7, 2022
1 parent 6d4e725 commit 6a06940
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/testdir/test_autocmd.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4706,
/**/
4705,
/**/
Expand Down
2 changes: 1 addition & 1 deletion src/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 6a06940

Please sign in to comment.