Fix serialization

This commit is contained in:
Zachary Yedidia
2019-06-15 15:50:37 -04:00
parent f5f4154d4c
commit adfeaf52ba
4 changed files with 28 additions and 12 deletions

View File

@@ -173,7 +173,7 @@ func NewBuffer(r io.Reader, size int64, path string, cursorPosition []string, bt
found := false
if len(path) > 0 {
for _, buf := range OpenBuffers {
if buf.AbsPath == absPath {
if buf.AbsPath == absPath && buf.Type != BTInfo {
found = true
b.SharedBuffer = buf.SharedBuffer
b.EventHandler = buf.EventHandler
@@ -245,6 +245,7 @@ func NewBuffer(r io.Reader, size int64, path string, cursorPosition []string, bt
func (b *Buffer) Close() {
for i, buf := range OpenBuffers {
if b == buf {
b.Fini()
copy(OpenBuffers[i:], OpenBuffers[i+1:])
OpenBuffers[len(OpenBuffers)-1] = nil
OpenBuffers = OpenBuffers[:len(OpenBuffers)-1]
@@ -253,6 +254,14 @@ func (b *Buffer) Close() {
}
}
// Fini should be called when a buffer is closed and performs
// some cleanup
func (b *Buffer) Fini() {
if !b.Modified() {
b.Serialize()
}
}
// GetName returns the name that should be displayed in the statusline
// for this buffer
func (b *Buffer) GetName() string {