Karsten Hopp 09dc61
To: vim_dev@googlegroups.com
Karsten Hopp 09dc61
Subject: Patch 7.4.645
Karsten Hopp 09dc61
Fcc: outbox
Karsten Hopp 09dc61
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 09dc61
Mime-Version: 1.0
Karsten Hopp 09dc61
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 09dc61
Content-Transfer-Encoding: 8bit
Karsten Hopp 09dc61
------------
Karsten Hopp 09dc61
Karsten Hopp 09dc61
Patch 7.4.645
Karsten Hopp 09dc61
Problem:    When splitting the window in a BufAdd autocommand while still in
Karsten Hopp 09dc61
	    the first, empty buffer the window count is wrong.
Karsten Hopp 09dc61
Solution:   Do not reset b_nwindows to zero and don't increment it.
Karsten Hopp 09dc61
Files:	    src/buffer.c, src/ex_cmds.c
Karsten Hopp 09dc61
Karsten Hopp 09dc61
Karsten Hopp 09dc61
*** ../vim-7.4.644/src/buffer.c	2015-01-27 18:43:42.134535513 +0100
Karsten Hopp 09dc61
--- src/buffer.c	2015-02-27 19:33:51.325459521 +0100
Karsten Hopp 09dc61
***************
Karsten Hopp 09dc61
*** 1794,1800 ****
Karsten Hopp 09dc61
  	if (aborting())		/* autocmds may abort script processing */
Karsten Hopp 09dc61
  	    return NULL;
Karsten Hopp 09dc61
  #endif
Karsten Hopp 09dc61
- 	/* buf->b_nwindows = 0; why was this here? */
Karsten Hopp 09dc61
  	free_buffer_stuff(buf, FALSE);	/* delete local variables et al. */
Karsten Hopp 09dc61
  
Karsten Hopp 09dc61
  	/* Init the options. */
Karsten Hopp 09dc61
--- 1794,1799 ----
Karsten Hopp 09dc61
***************
Karsten Hopp 09dc61
*** 1872,1877 ****
Karsten Hopp 09dc61
--- 1871,1879 ----
Karsten Hopp 09dc61
  #ifdef FEAT_AUTOCMD
Karsten Hopp 09dc61
      if (!(flags & BLN_DUMMY))
Karsten Hopp 09dc61
      {
Karsten Hopp 09dc61
+ 	/* Tricky: these autocommands may change the buffer list.  They could
Karsten Hopp 09dc61
+ 	 * also split the window with re-using the one empty buffer. This may
Karsten Hopp 09dc61
+ 	 * result in unexpectedly losing the empty buffer. */
Karsten Hopp 09dc61
  	apply_autocmds(EVENT_BUFNEW, NULL, NULL, FALSE, buf);
Karsten Hopp 09dc61
  	if (!buf_valid(buf))
Karsten Hopp 09dc61
  	    return NULL;
Karsten Hopp 09dc61
*** ../vim-7.4.644/src/ex_cmds.c	2015-02-17 12:17:10.837775002 +0100
Karsten Hopp 09dc61
--- src/ex_cmds.c	2015-02-27 19:28:47.232909242 +0100
Karsten Hopp 09dc61
***************
Karsten Hopp 09dc61
*** 3375,3381 ****
Karsten Hopp 09dc61
  	if (buf->b_ml.ml_mfp == NULL)		/* no memfile yet */
Karsten Hopp 09dc61
  	{
Karsten Hopp 09dc61
  	    oldbuf = FALSE;
Karsten Hopp 09dc61
- 	    buf->b_nwindows = 0;
Karsten Hopp 09dc61
  	}
Karsten Hopp 09dc61
  	else					/* existing memfile */
Karsten Hopp 09dc61
  	{
Karsten Hopp 09dc61
--- 3375,3380 ----
Karsten Hopp 09dc61
***************
Karsten Hopp 09dc61
*** 3408,3414 ****
Karsten Hopp 09dc61
  	 * Make the (new) buffer the one used by the current window.
Karsten Hopp 09dc61
  	 * If the old buffer becomes unused, free it if ECMD_HIDE is FALSE.
Karsten Hopp 09dc61
  	 * If the current buffer was empty and has no file name, curbuf
Karsten Hopp 09dc61
! 	 * is returned by buflist_new().
Karsten Hopp 09dc61
  	 */
Karsten Hopp 09dc61
  	if (buf != curbuf)
Karsten Hopp 09dc61
  	{
Karsten Hopp 09dc61
--- 3407,3413 ----
Karsten Hopp 09dc61
  	 * Make the (new) buffer the one used by the current window.
Karsten Hopp 09dc61
  	 * If the old buffer becomes unused, free it if ECMD_HIDE is FALSE.
Karsten Hopp 09dc61
  	 * If the current buffer was empty and has no file name, curbuf
Karsten Hopp 09dc61
! 	 * is returned by buflist_new(), nothing to do here.
Karsten Hopp 09dc61
  	 */
Karsten Hopp 09dc61
  	if (buf != curbuf)
Karsten Hopp 09dc61
  	{
Karsten Hopp 09dc61
***************
Karsten Hopp 09dc61
*** 3515,3522 ****
Karsten Hopp 09dc61
  	    au_new_curbuf = NULL;
Karsten Hopp 09dc61
  #endif
Karsten Hopp 09dc61
  	}
Karsten Hopp 09dc61
- 	else
Karsten Hopp 09dc61
- 	    ++curbuf->b_nwindows;
Karsten Hopp 09dc61
  
Karsten Hopp 09dc61
  	curwin->w_pcmark.lnum = 1;
Karsten Hopp 09dc61
  	curwin->w_pcmark.col = 0;
Karsten Hopp 09dc61
--- 3514,3519 ----
Karsten Hopp 09dc61
*** ../vim-7.4.644/src/version.c	2015-02-27 18:25:10.820179062 +0100
Karsten Hopp 09dc61
--- src/version.c	2015-02-27 19:33:06.153971911 +0100
Karsten Hopp 09dc61
***************
Karsten Hopp 09dc61
*** 743,744 ****
Karsten Hopp 09dc61
--- 743,746 ----
Karsten Hopp 09dc61
  {   /* Add new patch number below this line */
Karsten Hopp 09dc61
+ /**/
Karsten Hopp 09dc61
+     645,
Karsten Hopp 09dc61
  /**/
Karsten Hopp 09dc61
Karsten Hopp 09dc61
-- 
Karsten Hopp 09dc61
       He was not in the least bit scared to be mashed into a pulp
Karsten Hopp 09dc61
       Or to have his eyes gouged out and his elbows broken;
Karsten Hopp 09dc61
       To have his kneecaps split and his body burned away
Karsten Hopp 09dc61
       And his limbs all hacked and mangled, brave Sir Robin.
Karsten Hopp 09dc61
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
Karsten Hopp 09dc61
Karsten Hopp 09dc61
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 09dc61
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 09dc61
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 09dc61
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///