]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1538: :wqall does not trigger ExitPre v9.0.1538
authorBram Moolenaar <Bram@vim.org>
Wed, 10 May 2023 15:53:27 +0000 (16:53 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 10 May 2023 15:53:27 +0000 (16:53 +0100)
Problem:    :wqall does not trigger ExitPre. (Bart Libert)
Solution:   Move preparations for :qall to a common function. (closes #12374)

src/ex_cmds.c
src/ex_docmd.c
src/proto/ex_docmd.pro
src/testdir/test_exit.vim
src/version.c

index 085467e5830efa15c44f4a636b2e269cc24a6bc0..0fd6d10f71d6000356b55a46b4869dd3a00ef1ef 100644 (file)
@@ -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)
     {
index a0a718336663eff79db9a6253659008825aef820..430ca2ccb45550d6cd5871d46357b05d6e1ca9b7 100644 (file)
@@ -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);
index f5d7a488a719c47e9fa0b51dcf9e2ce9472a3050..3a1dc5fe4df9511bee9f7ead9e418923c19b5695 100644 (file)
@@ -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);
index 9e9370eee1edd6fd3744a5a5481c3688c546999f..b0446ba22bd88153649811540befe0ae21f0ca4e 100644 (file)
@@ -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
index 3a7dcb8278974c3e81561e3089bed0f0f8585bba..35a9708dcf53b60823cf49758233d2dde5b54fae 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1538,
 /**/
     1537,
 /**/