aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/main.c')
-rw-r--r--src/nvim/main.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/nvim/main.c b/src/nvim/main.c
index c7a60d07c1..d89ab7a2da 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -590,10 +590,13 @@ void getout(int exitval)
/* Trigger BufUnload for buffers that are loaded */
FOR_ALL_BUFFERS(buf) {
if (buf->b_ml.ml_mfp != NULL) {
- apply_autocmds(EVENT_BUFUNLOAD, buf->b_fname, buf->b_fname,
- FALSE, buf);
- if (!buf_valid(buf)) /* autocmd may delete the buffer */
+ bufref_T bufref;
+ set_bufref(&bufref, buf);
+ apply_autocmds(EVENT_BUFUNLOAD, buf->b_fname, buf->b_fname, false, buf);
+ if (!bufref_valid(&bufref)) {
+ // Autocmd deleted the buffer.
break;
+ }
}
}
apply_autocmds(EVENT_VIMLEAVEPRE, NULL, NULL, FALSE, curbuf);