summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2023-05-10 16:53:27 +0100
committerBram Moolenaar <Bram@vim.org>2023-05-10 16:53:27 +0100
commit411da64e77ef9d8edd1a5aa80fa5b9a4b159c93d (patch)
tree7843dd7517bea3b58977b700fe2e6cdb646ed76b
parent65b34868dac4bdc99e1144e36d5315b569795fc4 (diff)
downloadvim-git-411da64e77ef9d8edd1a5aa80fa5b9a4b159c93d.tar.gz
patch 9.0.1538: :wqall does not trigger ExitPrev9.0.1538
Problem: :wqall does not trigger ExitPre. (Bart Libert) Solution: Move preparations for :qall to a common function. (closes #12374)
-rw-r--r--src/ex_cmds.c4
-rw-r--r--src/ex_docmd.c24
-rw-r--r--src/proto/ex_docmd.pro1
-rw-r--r--src/testdir/test_exit.vim12
-rw-r--r--src/version.c2
5 files changed, 37 insertions, 6 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 085467e58..0fd6d10f7 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -2269,7 +2269,11 @@ do_wqall(exarg_T *eap)
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)
{
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index a0a718336..430ca2ccb 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -5957,10 +5957,11 @@ ex_cquit(exarg_T *eap UNUSED)
}
/*
- * ":qall": try to quit all windows
+ * Do preparations for "qall" and "wqall".
+ * Returns FAIL when quitting should be aborted.
*/
- static void
-ex_quit_all(exarg_T *eap)
+ int
+before_quit_all(exarg_T *eap)
{
if (cmdwin_type != 0)
{
@@ -5968,19 +5969,30 @@ ex_quit_all(exarg_T *eap)
cmdwin_result = K_XF1; // ex_window() takes care of this
else
cmdwin_result = K_XF2;
- return;
+ return FAIL;
}
// Don't quit while editing the command line.
if (text_locked())
{
text_locked_msg();
- return;
+ return FAIL;
}
if (before_quit_autocmds(curwin, TRUE, eap->forceit))
- return;
+ 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);
diff --git a/src/proto/ex_docmd.pro b/src/proto/ex_docmd.pro
index f5d7a488a..3a1dc5fe4 100644
--- a/src/proto/ex_docmd.pro
+++ b/src/proto/ex_docmd.pro
@@ -39,6 +39,7 @@ char_u *get_command_name(expand_T *xp, int idx);
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);
diff --git a/src/testdir/test_exit.vim b/src/testdir/test_exit.vim
index 9e9370eee..b0446ba22 100644
--- a/src/testdir/test_exit.vim
+++ b/src/testdir/test_exit.vim
@@ -81,6 +81,18 @@ func Test_exiting()
\ 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
diff --git a/src/version.c b/src/version.c
index 3a7dcb827..35a9708dc 100644
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1538,
+/**/
1537,
/**/
1536,