Patch 7.4.2328
Problem:    Crash when BufWinLeave autocmd goes to another tab page. (Hirohito
            Higashi)
Solution:   Make close_buffer() go back to the right window.
Files:      src/buffer.c, src/testdir/test_autocmd.vim


*** ../vim-7.4.2327/src/buffer.c        2016-09-04 19:57:53.193539060 +0200
--- src/buffer.c        2016-09-04 21:26:17.486209540 +0200
***************
*** 450,455 ****
--- 450,460 ----
      int               is_curbuf;
      int               nwindows;
      bufref_T  bufref;
+ # ifdef FEAT_WINDOWS
+     int               is_curwin = (curwin!= NULL && curwin->w_buffer == buf);
+     win_T     *the_curwin = curwin;
+     tabpage_T *the_curtab = curtab;
+ # endif
  #endif
      int               unload_buf = (action != 0);
      int               del_buf = (action == DOBUF_DEL || action == DOBUF_WIPE);
***************
*** 544,549 ****
--- 549,567 ----
            return;
  # endif
      }
+ 
+ # ifdef FEAT_WINDOWS
+     /* If the buffer was in curwin and the window has changed, go back to that
+      * window, if it still exists.  This avoids that ":edit x" triggering a
+      * "tabnext" BufUnload autocmd leaves a window behind without a buffer. */
+     if (is_curwin && curwin != the_curwin &&  win_valid_any_tab(the_curwin))
+     {
+       block_autocmds();
+       goto_tabpage_win(the_curtab, the_curwin);
+       unblock_autocmds();
+     }
+ # endif
+ 
      nwindows = buf->b_nwindows;
  #endif
  
*** ../vim-7.4.2327/src/testdir/test_autocmd.vim        2016-09-04 
19:50:50.520985732 +0200
--- src/testdir/test_autocmd.vim        2016-09-04 20:53:24.930517597 +0200
***************
*** 83,88 ****
--- 83,98 ----
    quit
  endfunc
  
+ function Test_autocmd_bufwinleave_with_tabfirst()
+   tabedit
+   augroup sample
+     autocmd!
+     autocmd BufWinLeave <buffer> tabfirst
+   augroup END
+   call setline(1, ['a', 'b', 'c'])
+   edit! a.txt
+ endfunc
+ 
  " SEGV occurs in older versions.  (At least 7.4.2321 or older)
  function Test_autocmd_bufunload_avoiding_SEGV_01()
    split aa.txt
*** ../vim-7.4.2327/src/version.c       2016-09-04 20:44:38.506814027 +0200
--- src/version.c       2016-09-04 21:32:06.343322216 +0200
***************
*** 765,766 ****
--- 765,768 ----
  {   /* Add new patch number below this line */
+ /**/
+     2328,
  /**/

-- 
"The question of whether computers can think is just like the question
of whether submarines can swim."      -- Edsger W. Dijkstra

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui