@@ -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 ;
@@ -804,6 +808,7 @@ buf_freeall(buf_T *buf, int flags)
804808
805809 // Make sure the buffer isn't closed by autocommands.
806810 ++ buf -> b_locked ;
811+ ++ buf -> b_locked_split ;
807812 set_bufref (& bufref , buf );
808813 if (buf -> b_ml .ml_mfp != NULL )
809814 {
@@ -830,6 +835,7 @@ buf_freeall(buf_T *buf, int flags)
830835 return ;
831836 }
832837 -- buf -> b_locked ;
838+ -- buf -> b_locked_split ;
833839
834840 // If the buffer was in curwin and the window has changed, go back to that
835841 // window, if it still exists. This avoids that ":edit x" triggering a
@@ -1722,8 +1728,8 @@ set_curbuf(buf_T *buf, int action)
17221728 set_bufref (& prevbufref , prevbuf );
17231729 set_bufref (& newbufref , buf );
17241730
1725- // Autocommands may delete the current buffer and/or the buffer we want to go
1726- // to. In those cases don't close the buffer.
1731+ // Autocommands may delete the current buffer and/or the buffer we want to
1732+ // go to. In those cases don't close the buffer.
17271733 if (!apply_autocmds (EVENT_BUFLEAVE , NULL , NULL , FALSE, curbuf )
17281734 || (bufref_valid (& prevbufref )
17291735 && bufref_valid (& newbufref )
0 commit comments