summaryrefslogtreecommitdiffstats
path: root/src/ex_docmd.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-05-29 14:30:43 +0200
committerBram Moolenaar <Bram@vim.org>2021-05-29 14:30:43 +0200
commit1174b018a6d705ddb8c04f3d21f78ae760aa0856 (patch)
tree1e7acb70f37f5755f15f001499dec24355304e9e /src/ex_docmd.c
parentf89be8de14cc9055d12f7b0f2c270a5bc09fc86c (diff)
patch 8.2.2900: QuitPre is triggered before :wq writes the filev8.2.2900
Problem: QuitPre is triggered before :wq writes the file, which is different from other commands. Solution: Trigger QuitPre after writing the file. (closes #8279)
Diffstat (limited to 'src/ex_docmd.c')
-rw-r--r--src/ex_docmd.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 58dad657ce..9c8eba558a 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -6089,7 +6089,7 @@ ex_stop(exarg_T *eap)
}
/*
- * ":exit", ":xit" and ":wq": Write file and quite the current window.
+ * ":exit", ":xit" and ":wq": Write file and quit the current window.
*/
static void
ex_exit(exarg_T *eap)
@@ -6112,17 +6112,17 @@ ex_exit(exarg_T *eap)
return;
}
- if (before_quit_autocmds(curwin, FALSE, eap->forceit))
- return;
-
/*
- * if more files or windows we won't exit
+ * we plan to exit if there is only one relevant window
*/
if (check_more(FALSE, eap->forceit) == OK && only_one_window())
exiting = TRUE;
- if ( ((eap->cmdidx == CMD_wq
- || curbufIsChanged())
- && do_write(eap) == FAIL)
+
+ // Write the buffer for ":wq" or when it was changed.
+ // Trigger QuitPre and ExitPre.
+ // Check if we can exit now, after autocommands have changed things.
+ if (((eap->cmdidx == CMD_wq || curbufIsChanged()) && do_write(eap) == FAIL)
+ || before_quit_autocmds(curwin, FALSE, eap->forceit)
|| check_more(TRUE, eap->forceit) == FAIL
|| (only_one_window() && check_changed_any(eap->forceit, FALSE)))
{