actions: Fix the iteration over a slice under modification in QuitAll() (#2898)

This commit is contained in:
Jöran Karl 2023-08-31 13:53:33 +02:00 committed by GitHub
parent ceaa143c62
commit a78c2c3509
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -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()

View File

@ -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 {