summaryrefslogtreecommitdiffstats
path: root/src/ex_docmd.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-10-19 12:37:42 +0200
committerBram Moolenaar <Bram@vim.org>2017-10-19 12:37:42 +0200
commit87ffb5c1a3aa506a1be07af4e794b3753f839dc3 (patch)
tree397eab50b1669ae9111a6f6fcdac4201abbb9503 /src/ex_docmd.c
parent6daeef1933be68055aabe1d55f8467d46a707753 (diff)
patch 8.0.1204: a QuitPre autocommand may get the wrong file namev8.0.1204
Problem: A QuitPre autocommand may get the wrong file name. Solution: Pass the buffer being closed to apply_autocmds(). (Rich Howe)
Diffstat (limited to 'src/ex_docmd.c')
-rw-r--r--src/ex_docmd.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 7365d1bd3a..905cdd4b04 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -7224,10 +7224,14 @@ ex_quit(exarg_T *eap)
wp = curwin;
#ifdef FEAT_AUTOCMD
- apply_autocmds(EVENT_QUITPRE, NULL, NULL, FALSE, curbuf);
- /* Refuse to quit when locked or when the buffer in the last window is
- * being closed (can only happen in autocommands). */
- if (curbuf_locked() || !win_valid(wp)
+ /* Refuse to quit when locked. */
+ if (curbuf_locked())
+ return;
+ apply_autocmds(EVENT_QUITPRE, NULL, NULL, FALSE, wp->w_buffer);
+ /* Bail out when autocommands closed the window.
+ * Refuse to quit when the buffer in the last window is being closed (can
+ * only happen in autocommands). */
+ if (!win_valid(wp)
|| (wp->w_buffer->b_nwindows == 1 && wp->w_buffer->b_locked > 0))
return;
#endif