vim-patch:7.4.1837 (#5834)

Problem:    The BufUnload event is triggered twice, when :bunload is used with
             set to  or .
Solution:   Do not trigger the event when ml_mfp is NULL. (Hirohito Higashi)

c67e892134
This commit is contained in:
lonerover
2016-12-28 06:39:21 +08:00
committed by Justin M. Keyes
parent 9066e23562
commit 1928b79e0c
3 changed files with 55 additions and 25 deletions

View File

@@ -509,9 +509,12 @@ void buf_freeall(buf_T *buf, int flags)
// Make sure the buffer isn't closed by autocommands.
buf->b_closing = true;
apply_autocmds(EVENT_BUFUNLOAD, buf->b_fname, buf->b_fname, FALSE, buf);
if (!buf_valid(buf)) /* autocommands may delete the buffer */
return;
if (buf->b_ml.ml_mfp != NULL) {
apply_autocmds(EVENT_BUFUNLOAD, buf->b_fname, buf->b_fname, false, buf);
if (!buf_valid(buf)) { // autocommands may delete the buffer
return;
}
}
if ((flags & BFA_DEL) && buf->b_p_bl) {
apply_autocmds(EVENT_BUFDELETE, buf->b_fname, buf->b_fname, FALSE, buf);
if (!buf_valid(buf)) /* autocommands may delete the buffer */