]> granicus.if.org Git - vim/commitdiff
patch 8.2.4700: buffer remains active if WinClosed event throws an exception v8.2.4700
authorBram Moolenaar <Bram@vim.org>
Wed, 6 Apr 2022 16:59:21 +0000 (17:59 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 6 Apr 2022 16:59:21 +0000 (17:59 +0100)
Problem:    Buffer remains active if a WinClosed event throws an exception.
Solution:   Ignore aborting() when closing the buffer. (closes #10097)

src/testdir/test_autocmd.vim
src/version.c
src/window.c

index 39ba9af7dcb42dd0d9b8a9de9992d2c2fa9f0f38..89023a1fb707d9c76b0d4844cc83ba7f4bebe1ac 100644 (file)
@@ -348,6 +348,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'
index 120633f0fa45518057e8858f875282f373e7bdc4..6900961a99adccb312f770e2765b2b91c40577e4 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4700,
 /**/
     4699,
 /**/
index 30fa80292dcda9167684d8f7c9073c3cdcfad533..8ec4823a982955f4ed28768260f1bbb3b98c2146 100644 (file)
@@ -2493,7 +2493,7 @@ win_close_buffer(win_T *win, int action, int abort_if_last)
 
        set_bufref(&bufref, curbuf);
        win->w_closing = TRUE;
-       close_buffer(win, win->w_buffer, action, abort_if_last, FALSE);
+       close_buffer(win, win->w_buffer, action, abort_if_last, TRUE);
        if (win_valid_any_tab(win))
            win->w_closing = FALSE;
        // Make sure curbuf is valid. It can become invalid if 'bufhidden' is