From 30a34136b6d81b795eeb0ee435d410fc74da9639 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 29 May 2021 09:53:33 -0400 Subject: vim-patch:8.2.2898: QuitPre and ExitPre not triggered when GUI window is closed Problem: QuitPre and ExitPre not triggered when GUI window is closed. Solution: Call before_quit_autocmds(). (closes vim/vim#8242) https://github.com/vim/vim/commit/3552e742898cd57adaf9b8ce32a9056271eab8d2 --- src/nvim/ex_docmd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/ex_docmd.c') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index c93f9fe6f2..92ed4b047c 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -6340,7 +6340,7 @@ void not_exiting(void) exiting = false; } -static bool before_quit_autocmds(win_T *wp, bool quit_all, int forceit) +bool before_quit_autocmds(win_T *wp, bool quit_all, int forceit) { apply_autocmds(EVENT_QUITPRE, NULL, NULL, false, wp->w_buffer); @@ -6406,7 +6406,7 @@ static void ex_quit(exarg_T *eap) return; } - // If there are more files or windows we won't exit. + // If there is only one relevant window we will exit. if (check_more(false, eap->forceit) == OK && only_one_window()) { exiting = true; } -- cgit From ca6a8ac93c6425e0480fc4b4efa8519701ce2394 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 29 May 2021 09:59:33 -0400 Subject: vim-patch:8.2.2900: QuitPre is triggered before :wq writes the file Problem: QuitPre is triggered before :wq writes the file, which is different from other commands. Solution: Trigger QuitPre after writing the file. (closes vim/vim#8279) https://github.com/vim/vim/commit/1174b018a6d705ddb8c04f3d21f78ae760aa0856 --- src/nvim/ex_docmd.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'src/nvim/ex_docmd.c') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 92ed4b047c..29347def4c 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -5017,7 +5017,7 @@ char_u *check_nextcmd(char_u *p) static int check_more( int message, // when FALSE check only, no messages - int forceit + bool forceit ) { int n = ARGCOUNT - curwin->w_arg_idx - 1; @@ -6340,7 +6340,7 @@ void not_exiting(void) exiting = false; } -bool before_quit_autocmds(win_T *wp, bool quit_all, int forceit) +bool before_quit_autocmds(win_T *wp, bool quit_all, bool forceit) { apply_autocmds(EVENT_QUITPRE, NULL, NULL, false, wp->w_buffer); @@ -6749,7 +6749,7 @@ static void ex_stop(exarg_T *eap) apply_autocmds(EVENT_VIMRESUME, NULL, NULL, false, NULL); } -// ":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) { if (cmdwin_type != 0) { @@ -6762,17 +6762,15 @@ static void 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))) { not_exiting(); -- cgit