@@ -355,9 +355,9 @@ func NewBufferFromString(text, path string, btype BufType) *Buffer {
355355// Places the cursor at startcursor. If startcursor is -1, -1 places the
356356// cursor at an autodetected location (based on savecursor or :LINE:COL)
357357func NewBuffer (r io.Reader , size int64 , path string , btype BufType , cmd Command ) * Buffer {
358- absPath , err := filepath . Abs ( path )
359- if err != nil {
360- absPath = path
358+ absPath := path
359+ if btype == BTDefault && path != "" {
360+ absPath = util . ResolvePath ( path )
361361 }
362362
363363 b := new (Buffer )
@@ -391,6 +391,7 @@ func NewBuffer(r io.Reader, size int64, path string, btype BufType, cmd Command)
391391 }
392392 config .UpdatePathGlobLocals (b .Settings , absPath )
393393
394+ var err error
394395 b .encoding , err = htmlindex .Get (b .Settings ["encoding" ].(string ))
395396 if err != nil {
396397 b .encoding = unicode .UTF8
@@ -489,7 +490,7 @@ func NewBuffer(r io.Reader, size int64, path string, btype BufType, cmd Command)
489490 }
490491 }
491492
492- err = config .RunPluginFn ("onBufferOpen" , luar .New (ulua .L , b ))
493+ err : = config .RunPluginFn ("onBufferOpen" , luar .New (ulua .L , b ))
493494 if err != nil {
494495 screen .TermMessage (err )
495496 }
@@ -524,10 +525,12 @@ func (b *Buffer) Close() {
524525// Fini should be called when a buffer is closed and performs
525526// some cleanup
526527func (b * Buffer ) Fini () {
527- if ! b .Modified () {
528- b .Serialize ()
528+ if ! b .Shared () {
529+ if ! b .Modified () {
530+ b .Serialize ()
531+ }
532+ b .CancelBackup ()
529533 }
530- b .CancelBackup ()
531534
532535 if b .Type == BTStdout {
533536 fmt .Fprint (util .Stdout , string (b .Bytes ()))
0 commit comments