Skip to content

Commit da44d1d

Browse files
committed
updated for version 7.4.645
Problem: When splitting the window in a BufAdd autocommand while still in the first, empty buffer the window count is wrong. Solution: Do not reset b_nwindows to zero and don't increment it.
1 parent 5f0ed7d commit da44d1d

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

src/buffer.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1794,7 +1794,6 @@ buflist_new(ffname, sfname, lnum, flags)
17941794
if (aborting()) /* autocmds may abort script processing */
17951795
return NULL;
17961796
#endif
1797-
/* buf->b_nwindows = 0; why was this here? */
17981797
free_buffer_stuff(buf, FALSE); /* delete local variables et al. */
17991798

18001799
/* Init the options. */
@@ -1872,6 +1871,9 @@ buflist_new(ffname, sfname, lnum, flags)
18721871
#ifdef FEAT_AUTOCMD
18731872
if (!(flags & BLN_DUMMY))
18741873
{
1874+
/* Tricky: these autocommands may change the buffer list. They could
1875+
* also split the window with re-using the one empty buffer. This may
1876+
* result in unexpectedly losing the empty buffer. */
18751877
apply_autocmds(EVENT_BUFNEW, NULL, NULL, FALSE, buf);
18761878
if (!buf_valid(buf))
18771879
return NULL;

src/ex_cmds.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3375,7 +3375,6 @@ do_ecmd(fnum, ffname, sfname, eap, newlnum, flags, oldwin)
33753375
if (buf->b_ml.ml_mfp == NULL) /* no memfile yet */
33763376
{
33773377
oldbuf = FALSE;
3378-
buf->b_nwindows = 0;
33793378
}
33803379
else /* existing memfile */
33813380
{
@@ -3408,7 +3407,7 @@ do_ecmd(fnum, ffname, sfname, eap, newlnum, flags, oldwin)
34083407
* Make the (new) buffer the one used by the current window.
34093408
* If the old buffer becomes unused, free it if ECMD_HIDE is FALSE.
34103409
* If the current buffer was empty and has no file name, curbuf
3411-
* is returned by buflist_new().
3410+
* is returned by buflist_new(), nothing to do here.
34123411
*/
34133412
if (buf != curbuf)
34143413
{
@@ -3515,8 +3514,6 @@ do_ecmd(fnum, ffname, sfname, eap, newlnum, flags, oldwin)
35153514
au_new_curbuf = NULL;
35163515
#endif
35173516
}
3518-
else
3519-
++curbuf->b_nwindows;
35203517

35213518
curwin->w_pcmark.lnum = 1;
35223519
curwin->w_pcmark.col = 0;

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ static char *(features[]) =
741741

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
645,
744746
/**/
745747
644,
746748
/**/

0 commit comments

Comments
 (0)