diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 94f327726d..8f83686f4e 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -3663,7 +3663,7 @@ void ex_buffer_all(exarg_T *eap) : wp->w_width != Columns) || (had_tab > 0 && wp != firstwin)) && !ONE_WINDOW - && !(win_locked(curwin) || wp->w_buffer->b_locked > 0) + && !(win_locked(wp) || wp->w_buffer->b_locked > 0) && !is_aucmd_win(wp)) { if (win_close(wp, false, false) == FAIL) { break; diff --git a/src/nvim/memory.c b/src/nvim/memory.c index ec82848138..50062122e8 100644 --- a/src/nvim/memory.c +++ b/src/nvim/memory.c @@ -950,6 +950,8 @@ void free_all_mem(void) bufref_T bufref; set_bufref(&bufref, buf); nextbuf = buf->b_next; + // All windows were freed. Reset b_nwindows so buffers can be wiped. + buf->b_nwindows = 0; // Since options (in addition to other stuff) have been freed above we need to ensure no // callbacks are called, so free them before closing the buffer.