mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-30 06:37:14 +09:00
Fix serialization
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user