@@ -2172,8 +2172,9 @@ close_last_window_tabpage(win, free_buf, prev_curtab)
21722172 * If "free_buf" is TRUE related buffer may be unloaded.
21732173 *
21742174 * Called by :quit, :close, :xit, :wq and findtag().
2175+ * Returns FAIL when the window was not closed.
21752176 */
2176- void
2177+ int
21772178win_close (win , free_buf )
21782179 win_T * win ;
21792180 int free_buf ;
@@ -2190,29 +2191,29 @@ win_close(win, free_buf)
21902191 if (last_window ())
21912192 {
21922193 EMSG (_ ("E444: Cannot close last window" ));
2193- return ;
2194+ return FAIL ;
21942195 }
21952196
21962197#ifdef FEAT_AUTOCMD
21972198 if (win -> w_closing || (win -> w_buffer != NULL && win -> w_buffer -> b_closing ))
2198- return ; /* window is already being closed */
2199+ return FAIL ; /* window is already being closed */
21992200 if (win == aucmd_win )
22002201 {
22012202 EMSG (_ ("E813: Cannot close autocmd window" ));
2202- return ;
2203+ return FAIL ;
22032204 }
22042205 if ((firstwin == aucmd_win || lastwin == aucmd_win ) && one_window ())
22052206 {
22062207 EMSG (_ ("E814: Cannot close window, only autocmd window would remain" ));
2207- return ;
2208+ return FAIL ;
22082209 }
22092210#endif
22102211
22112212 /* When closing the last window in a tab page first go to another tab page
22122213 * and then close the window and the tab page to avoid that curwin and
22132214 * curtab are invalid while we are freeing memory. */
22142215 if (close_last_window_tabpage (win , free_buf , prev_curtab ))
2215- return ;
2216+ return FAIL ;
22162217
22172218 /* When closing the help window, try restoring a snapshot after closing
22182219 * the window. Otherwise clear the snapshot, it's now invalid. */
@@ -2240,22 +2241,22 @@ win_close(win, free_buf)
22402241 win -> w_closing = TRUE;
22412242 apply_autocmds (EVENT_BUFLEAVE , NULL , NULL , FALSE, curbuf );
22422243 if (!win_valid (win ))
2243- return ;
2244+ return FAIL ;
22442245 win -> w_closing = FALSE;
22452246 if (last_window ())
2246- return ;
2247+ return FAIL ;
22472248 }
22482249 win -> w_closing = TRUE;
22492250 apply_autocmds (EVENT_WINLEAVE , NULL , NULL , FALSE, curbuf );
22502251 if (!win_valid (win ))
2251- return ;
2252+ return FAIL ;
22522253 win -> w_closing = FALSE;
22532254 if (last_window ())
2254- return ;
2255+ return FAIL ;
22552256# ifdef FEAT_EVAL
22562257 /* autocmds may abort script processing */
22572258 if (aborting ())
2258- return ;
2259+ return FAIL ;
22592260# endif
22602261 }
22612262#endif
@@ -2303,7 +2304,7 @@ win_close(win, free_buf)
23032304 * other window or moved to another tab page. */
23042305 else if (!win_valid (win ) || last_window () || curtab != prev_curtab
23052306 || close_last_window_tabpage (win , free_buf , prev_curtab ))
2306- return ;
2307+ return FAIL ;
23072308
23082309 /* Free the memory used for the window and get the window that received
23092310 * the screen space. */
@@ -2383,6 +2384,7 @@ win_close(win, free_buf)
23832384#endif
23842385
23852386 redraw_all_later (NOT_VALID );
2387+ return OK ;
23862388}
23872389
23882390/*
0 commit comments