mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-15 21:37:09 +09:00
actions: Fix the iteration over a slice under modification in QuitAll() (#2898)
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user