]> granicus.if.org Git - vim/commitdiff
patch 8.2.4706: buffer remains active with WinClosed and tabpages v8.2.4706
authorzeertzjq <zeertzjq@outlook.com>
Thu, 7 Apr 2022 13:08:29 +0000 (14:08 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 7 Apr 2022 13:08:29 +0000 (14:08 +0100)
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)

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

index 89023a1fb707d9c76b0d4844cc83ba7f4bebe1ac..eb1fa046c59575b5130d4d7f037e13a72a073810 100644 (file)
@@ -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'
index 62623614a20037db8a4bad1d3f12bfad73219095..d0205d7e33d704e0a7df5377853efd3e2b930de6 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4706,
 /**/
     4705,
 /**/
index 8ec4823a982955f4ed28768260f1bbb3b98c2146..f7634758924bfad6acdd488c181a011b7be89ac3 100644 (file)
@@ -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.