]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.2095: :wqall! doesn't quit when using :quit in BufWritePost v9.1.2095
authorzeertzjq <zeertzjq@outlook.com>
Mon, 19 Jan 2026 18:15:51 +0000 (18:15 +0000)
committerChristian Brabandt <cb@256bit.org>
Mon, 19 Jan 2026 18:15:51 +0000 (18:15 +0000)
Problem:  :wqall! doesn't quit when using :quit in BufWritePost
          (after 8.0.1190).
Solution: Restore old value of "exiting" when calling not_exiting()
          instead of always resetting it to FALSE (zeertzjq).

related: #2205
closes:  #19212

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/ex_cmds.c
src/ex_docmd.c
src/proto/ex_docmd.pro
src/testdir/test_exit.vim
src/version.c

index c9b4974c2b0c08714a25acefc2f47dec82eafa41..bd31de6d1b58a11a648bcdb86b0c9e9be19a1507 100644 (file)
@@ -2498,6 +2498,7 @@ do_wqall(exarg_T *eap)
     buf_T      *buf;
     int                error = 0;
     int                save_forceit = eap->forceit;
+    int                save_exiting = exiting;
 
     if (eap->cmdidx == CMD_xall || eap->cmdidx == CMD_wqall)
     {
@@ -2564,7 +2565,7 @@ do_wqall(exarg_T *eap)
     {
        if (!error)
            getout(0);          // exit Vim
-       not_exiting();
+       not_exiting(save_exiting);
     }
 }
 
index 0a6e940d6b2ffbba8492c82fef7975a5ac4b4d56..42ca2e7bff0be5dacd3c308741865ca8a0551633 100644 (file)
@@ -6062,9 +6062,9 @@ ex_highlight(exarg_T *eap)
  * (because of an error).  May need to restore the terminal mode.
  */
     void
-not_exiting(void)
+not_exiting(int save_exiting)
 {
-    exiting = FALSE;
+    exiting = save_exiting;
     settmode(TMODE_RAW);
 }
 
@@ -6139,6 +6139,7 @@ ex_quit(exarg_T *eap)
     netbeansForcedQuit = eap->forceit;
 #endif
 
+    int save_exiting = exiting;
     /*
      * If there is only one relevant window we will exit.
      */
@@ -6151,7 +6152,7 @@ ex_quit(exarg_T *eap)
            || check_more(TRUE, eap->forceit) == FAIL
            || (only_one_window() && check_changed_any(eap->forceit, TRUE)))
     {
-       not_exiting();
+       not_exiting(save_exiting);
     }
     else
     {
@@ -6163,7 +6164,7 @@ ex_quit(exarg_T *eap)
        // :h|wincmd w|q      - quit
        if (only_one_window() && (ONE_WINDOW || eap->addr_count == 0))
            getout(0);
-       not_exiting();
+       not_exiting(save_exiting);
 #ifdef FEAT_GUI
        need_mouse_correct = TRUE;
 #endif
@@ -6219,10 +6220,11 @@ ex_quit_all(exarg_T *eap)
 {
     if (before_quit_all(eap) == FAIL)
        return;
+    int save_exiting = exiting;
     exiting = TRUE;
     if (eap->forceit || !check_changed_any(FALSE, FALSE))
        getout(0);
-    not_exiting();
+    not_exiting(save_exiting);
 }
 
 /*
@@ -6725,6 +6727,7 @@ ex_exit(exarg_T *eap)
        return;
     }
 
+    int save_exiting = exiting;
     /*
      * we plan to exit if there is only one relevant window
      */
@@ -6739,13 +6742,13 @@ ex_exit(exarg_T *eap)
            || check_more(TRUE, eap->forceit) == FAIL
            || (only_one_window() && check_changed_any(eap->forceit, FALSE)))
     {
-       not_exiting();
+       not_exiting(save_exiting);
     }
     else
     {
        if (only_one_window())      // quit last window, exit Vim
            getout(0);
-       not_exiting();
+       not_exiting(save_exiting);
 #ifdef FEAT_GUI
        need_mouse_correct = TRUE;
 #endif
index c79d5b4d7a9aee45f5d79bcd6aa13c5b1aa64a9b..afaec22827b3ef58151594c5eef029e4b603938e 100644 (file)
@@ -38,7 +38,7 @@ char_u *find_nextcmd(char_u *p);
 char_u *check_nextcmd(char_u *p);
 void set_nextcmd(exarg_T *eap, char_u *arg);
 char_u *get_command_name(expand_T *xp, int idx);
-void not_exiting(void);
+void not_exiting(int save_exiting);
 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);
index 3e0919a02e8c3831e7b6b3a9e437bf84f75533dc..77852f21d8589c027bd0cbc07f2150d038b49a71 100644 (file)
@@ -90,6 +90,20 @@ func Test_exiting()
     call assert_equal(['QuitPre', 'ExitPre'], readfile('Xtestout'))
   endif
   call delete('Xtestout')
+
+  " Test using :quit in BufWritePost during :wqall
+  let after =<< trim [CODE]
+    botright new Xwritebuf
+    call setline(1, 'SHOULD BE WRITTEN')
+    autocmd BufWritePost Xwritebuf 1quit
+    wqall
+    call setline(1, 'NOT REACHED') | write | qall
+  [CODE]
+
+  if RunVim([], after, '')
+    call assert_equal(['SHOULD BE WRITTEN'], readfile('Xwritebuf'))
+  endif
+  call delete('Xwritebuf')
 endfunc
 
 " Test for getting the Vim exit code from v:exiting
index fe5a71b227c3168b248ddde3a2ebffe1666d0db2..4b9fa37d7e5c61837a17b5a96745fed7f8ff923b 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2095,
 /**/
     2094,
 /**/