diff options
Diffstat (limited to 'src/nvim/buffer.c')
-rw-r--r-- | src/nvim/buffer.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 80db0e2ebc..d9fdc80c60 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -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 */ |