Patch 9.0.1538

4 views
Skip to first unread message

Bram Moolenaar

unread,
May 10, 2023, 11:54:03 AM5/10/23
to vim...@googlegroups.com

Patch 9.0.1538
Problem: :wqall does not trigger ExitPre. (Bart Libert)
Solution: Move preparations for :qall to a common function. (closes #12374)
Files: src/ex_docmd.c, src/proto/ex_docmd.pro, src/ex_cmds.c,
src/testdir/test_exit.vim


*** ../vim-9.0.1537/src/ex_docmd.c 2023-05-05 22:58:30.805061562 +0100
--- src/ex_docmd.c 2023-05-10 16:45:45.318977303 +0100
***************
*** 5957,5966 ****
}

/*
! * ":qall": try to quit all windows
*/
! static void
! ex_quit_all(exarg_T *eap)
{
if (cmdwin_type != 0)
{
--- 5957,5967 ----
}

/*
! * Do preparations for "qall" and "wqall".
! * Returns FAIL when quitting should be aborted.
*/
! int
! before_quit_all(exarg_T *eap)
{
if (cmdwin_type != 0)
{
***************
*** 5968,5986 ****
cmdwin_result = K_XF1; // ex_window() takes care of this
else
cmdwin_result = K_XF2;
! return;
}

// Don't quit while editing the command line.
if (text_locked())
{
text_locked_msg();
! return;
}

if (before_quit_autocmds(curwin, TRUE, eap->forceit))
! return;

exiting = TRUE;
if (eap->forceit || !check_changed_any(FALSE, FALSE))
getout(0);
--- 5969,5998 ----
cmdwin_result = K_XF1; // ex_window() takes care of this
else
cmdwin_result = K_XF2;
! return FAIL;
}

// Don't quit while editing the command line.
if (text_locked())
{
text_locked_msg();
! return FAIL;
}

if (before_quit_autocmds(curwin, TRUE, eap->forceit))
! return FAIL;
!
! return OK;
! }

+ /*
+ * ":qall": try to quit all windows
+ */
+ static void
+ ex_quit_all(exarg_T *eap)
+ {
+ if (before_quit_all(eap) == FAIL)
+ return;
exiting = TRUE;
if (eap->forceit || !check_changed_any(FALSE, FALSE))
getout(0);
*** ../vim-9.0.1537/src/proto/ex_docmd.pro 2022-09-01 16:00:49.730496296 +0100
--- src/proto/ex_docmd.pro 2023-05-10 16:47:47.487359104 +0100
***************
*** 39,44 ****
--- 39,45 ----
void not_exiting(void);
int before_quit_autocmds(win_T *wp, int quit_all, int forceit);
void ex_quit(exarg_T *eap);
+ int before_quit_all(exarg_T *eap);
void tabpage_close(int forceit);
void tabpage_close_other(tabpage_T *tp, int forceit);
void ex_stop(exarg_T *eap);
*** ../vim-9.0.1537/src/ex_cmds.c 2023-04-22 22:54:28.045802345 +0100
--- src/ex_cmds.c 2023-05-10 16:52:13.727961744 +0100
***************
*** 2269,2275 ****
--- 2269,2279 ----
int save_forceit = eap->forceit;

if (eap->cmdidx == CMD_xall || eap->cmdidx == CMD_wqall)
+ {
+ if (before_quit_all(eap) == FAIL)
+ return;
exiting = TRUE;
+ }

FOR_ALL_BUFFERS(buf)
{
*** ../vim-9.0.1537/src/testdir/test_exit.vim 2022-09-21 21:59:58.273433517 +0100
--- src/testdir/test_exit.vim 2023-05-10 16:51:34.507888606 +0100
***************
*** 81,86 ****
--- 81,98 ----
\ readfile('Xtestout'))
endif
call delete('Xtestout')
+
+ " ExitPre autocommand also executed on :wqall
+ let after =<< trim [CODE]
+ au QuitPre * call writefile(["QuitPre"], "Xtestout", "a")
+ au ExitPre * call writefile(["ExitPre"], "Xtestout", "a")
+ wqall
+ [CODE]
+
+ if RunVim([], after, '')
+ call assert_equal(['QuitPre', 'ExitPre'], readfile('Xtestout'))
+ endif
+ call delete('Xtestout')
endfunc

" Test for getting the Vim exit code from v:exiting
*** ../vim-9.0.1537/src/version.c 2023-05-10 14:47:46.536046589 +0100
--- src/version.c 2023-05-10 16:46:55.303205878 +0100
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 1538,
/**/

--
How To Keep A Healthy Level Of Insanity:
4. Put your garbage can on your desk and label it "in".

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages