@@ -595,6 +595,7 @@ close_buffer(
595595 if (buf -> b_nwindows == 1 )
596596 {
597597 ++ buf -> b_locked ;
598+ ++ buf -> b_locked_split ;
598599 if (apply_autocmds (EVENT_BUFWINLEAVE , buf -> b_fname , buf -> b_fname ,
599600 FALSE, buf )
600601 && !bufref_valid (& bufref ))
@@ -605,6 +606,7 @@ close_buffer(
605606 return FALSE;
606607 }
607608 -- buf -> b_locked ;
609+ -- buf -> b_locked_split ;
608610 if (abort_if_last && one_window ())
609611 // Autocommands made this the only window.
610612 goto aucmd_abort ;
@@ -614,12 +616,14 @@ close_buffer(
614616 if (!unload_buf )
615617 {
616618 ++ buf -> b_locked ;
619+ ++ buf -> b_locked_split ;
617620 if (apply_autocmds (EVENT_BUFHIDDEN , buf -> b_fname , buf -> b_fname ,
618621 FALSE, buf )
619622 && !bufref_valid (& bufref ))
620623 // Autocommands deleted the buffer.
621624 goto aucmd_abort ;
622625 -- buf -> b_locked ;
626+ -- buf -> b_locked_split ;
623627 if (abort_if_last && one_window ())
624628 // Autocommands made this the only window.
625629 goto aucmd_abort ;
@@ -800,6 +804,7 @@ buf_freeall(buf_T *buf, int flags)
800804
801805 // Make sure the buffer isn't closed by autocommands.
802806 ++ buf -> b_locked ;
807+ ++ buf -> b_locked_split ;
803808 set_bufref (& bufref , buf );
804809 if (buf -> b_ml .ml_mfp != NULL )
805810 {
@@ -826,6 +831,7 @@ buf_freeall(buf_T *buf, int flags)
826831 return ;
827832 }
828833 -- buf -> b_locked ;
834+ -- buf -> b_locked_split ;
829835
830836 // If the buffer was in curwin and the window has changed, go back to that
831837 // window, if it still exists. This avoids that ":edit x" triggering a
@@ -1718,8 +1724,8 @@ set_curbuf(buf_T *buf, int action)
17181724 set_bufref (& prevbufref , prevbuf );
17191725 set_bufref (& newbufref , buf );
17201726
1721- // Autocommands may delete the current buffer and/or the buffer we want to go
1722- // to. In those cases don't close the buffer.
1727+ // Autocommands may delete the current buffer and/or the buffer we want to
1728+ // go to. In those cases don't close the buffer.
17231729 if (!apply_autocmds (EVENT_BUFLEAVE , NULL , NULL , FALSE, curbuf )
17241730 || (bufref_valid (& prevbufref )
17251731 && bufref_valid (& newbufref )
0 commit comments