diff --git a/internal/action/actions.go b/internal/action/actions.go index 2b36795a..74e701f4 100644 --- a/internal/action/actions.go +++ b/internal/action/actions.go @@ -1582,9 +1582,7 @@ func (h *BufPane) QuitAll() bool { } quit := func() { - for _, b := range buffer.OpenBuffers { - b.Close() - } + buffer.CloseOpenBuffers() screen.Screen.Fini() InfoBar.Close() runtime.Goexit() diff --git a/internal/buffer/buffer.go b/internal/buffer/buffer.go index 38461fbf..6365cec0 100644 --- a/internal/buffer/buffer.go +++ b/internal/buffer/buffer.go @@ -430,6 +430,15 @@ func NewBuffer(r io.Reader, size int64, path string, startcursor Loc, btype BufT return b } +// CloseOpenBuffers removes all open buffers +func CloseOpenBuffers() { + for i, buf := range OpenBuffers { + buf.Fini() + OpenBuffers[i] = nil + } + OpenBuffers = OpenBuffers[:0] +} + // Close removes this buffer from the list of open buffers func (b *Buffer) Close() { for i, buf := range OpenBuffers {