@@ -492,8 +492,10 @@ can_unload_buffer(buf_T *buf)
492492 * supposed to close the window but autocommands close all other windows.
493493 *
494494 * When "ignore_abort" is TRUE don't abort even when aborting() returns TRUE.
495+ *
496+ * Return TRUE when we got to the end and b_nwindows was decremented.
495497 */
496- void
498+ int
497499close_buffer (
498500 win_T * win , // if not NULL, set b_last_cursor
499501 buf_T * buf ,
@@ -540,7 +542,7 @@ close_buffer(
540542 if (wipe_buf || unload_buf )
541543 {
542544 if (!can_unload_buffer (buf ))
543- return ;
545+ return FALSE ;
544546
545547 // Wiping out or unloading a terminal buffer kills the job.
546548 free_terminal (buf );
@@ -571,7 +573,7 @@ close_buffer(
571573 // Disallow deleting the buffer when it is locked (already being closed or
572574 // halfway a command that relies on it). Unloading is allowed.
573575 if ((del_buf || wipe_buf ) && !can_unload_buffer (buf ))
574- return ;
576+ return FALSE ;
575577
576578 // check no autocommands closed the window
577579 if (win != NULL && win_valid_any_tab (win ))
@@ -600,7 +602,7 @@ close_buffer(
600602 // Autocommands deleted the buffer.
601603aucmd_abort :
602604 emsg (_ (e_auabort ));
603- return ;
605+ return FALSE ;
604606 }
605607 -- buf -> b_locked ;
606608 if (abort_if_last && one_window ())
@@ -625,7 +627,7 @@ close_buffer(
625627#ifdef FEAT_EVAL
626628 // autocmds may abort script processing
627629 if (!ignore_abort && aborting ())
628- return ;
630+ return FALSE ;
629631#endif
630632 }
631633
@@ -653,7 +655,7 @@ close_buffer(
653655 // Return when a window is displaying the buffer or when it's not
654656 // unloaded.
655657 if (buf -> b_nwindows > 0 || !unload_buf )
656- return ;
658+ return FALSE ;
657659
658660 // Always remove the buffer when there is no file name.
659661 if (buf -> b_ffname == NULL )
@@ -683,11 +685,11 @@ close_buffer(
683685
684686 // Autocommands may have deleted the buffer.
685687 if (!bufref_valid (& bufref ))
686- return ;
688+ return FALSE ;
687689#ifdef FEAT_EVAL
688690 // autocmds may abort script processing
689691 if (!ignore_abort && aborting ())
690- return ;
692+ return FALSE ;
691693#endif
692694
693695 /*
@@ -698,7 +700,7 @@ close_buffer(
698700 * deleted buffer.
699701 */
700702 if (buf == curbuf && !is_curbuf )
701- return ;
703+ return FALSE ;
702704
703705 if (win_valid_any_tab (win ) && win -> w_buffer == buf )
704706 win -> w_buffer = NULL ; // make sure we don't use the buffer now
@@ -755,6 +757,7 @@ close_buffer(
755757 buf -> b_p_bl = FALSE;
756758 }
757759 // NOTE: at this point "curbuf" may be invalid!
760+ return TRUE;
758761}
759762
760763/*
0 commit comments