mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-25 18:07:07 +09:00
Never backup closed buffers
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/zyedidia/micro/v2/internal/config"
|
"github.com/zyedidia/micro/v2/internal/config"
|
||||||
@@ -36,7 +37,10 @@ func backupThread() {
|
|||||||
|
|
||||||
for len(backupRequestChan) > 0 {
|
for len(backupRequestChan) > 0 {
|
||||||
b := <-backupRequestChan
|
b := <-backupRequestChan
|
||||||
b.Backup()
|
bfini := atomic.LoadInt32(&(b.fini)) != 0
|
||||||
|
if !bfini {
|
||||||
|
b.Backup()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
luar "layeh.com/gopher-luar"
|
luar "layeh.com/gopher-luar"
|
||||||
@@ -184,6 +185,7 @@ type Buffer struct {
|
|||||||
*EventHandler
|
*EventHandler
|
||||||
*SharedBuffer
|
*SharedBuffer
|
||||||
|
|
||||||
|
fini int32
|
||||||
cursors []*Cursor
|
cursors []*Cursor
|
||||||
curCursor int
|
curCursor int
|
||||||
StartCursor Loc
|
StartCursor Loc
|
||||||
@@ -396,6 +398,8 @@ func (b *Buffer) Fini() {
|
|||||||
if b.Type == BTStdout {
|
if b.Type == BTStdout {
|
||||||
fmt.Fprint(util.Stdout, string(b.Bytes()))
|
fmt.Fprint(util.Stdout, string(b.Bytes()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
atomic.StoreInt32(&(b.fini), int32(1))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetName returns the name that should be displayed in the statusline
|
// GetName returns the name that should be displayed in the statusline
|
||||||
|
|||||||
Reference in New Issue
Block a user