vim-patch:8.0.1204: a QuitPre autocommand may get the wrong file name

Problem:    A QuitPre autocommand may get the wrong file name.
Solution:   Pass the buffer being closed to apply_autocmds(). (Rich Howe)

87ffb5c1a3
This commit is contained in:
Justin M. Keyes 2018-02-02 20:39:48 +01:00
parent b5acf6e0c1
commit 070f8df4dd

View File

@ -5974,16 +5974,18 @@ static void ex_quit(exarg_T *eap)
wp = curwin; wp = curwin;
} }
apply_autocmds(EVENT_QUITPRE, NULL, NULL, false, curbuf); // Refuse to quit when locked.
if (curbuf_locked()) {
return;
}
apply_autocmds(EVENT_QUITPRE, NULL, NULL, false, wp->w_buffer);
// Refuse to quit when locked or when the buffer in the last window is // Refuse to quit when locked or when the buffer in the last window is
// being closed (can only happen in autocommands). // being closed (can only happen in autocommands).
if (curbuf_locked() if (!win_valid(wp)
|| !win_valid(wp)
|| (wp->w_buffer->b_nwindows == 1 && wp->w_buffer->b_locked > 0)) { || (wp->w_buffer->b_nwindows == 1 && wp->w_buffer->b_locked > 0)) {
return; return;
} }
/* /*
* If there are more files or windows we won't exit. * If there are more files or windows we won't exit.
*/ */