save: Update the modification time of the buffer only in case of file changes

This commit is contained in:
Jöran Karl 2025-01-19 13:38:29 +01:00
parent 49aebe8aca
commit 6164050425

View File

@ -263,12 +263,6 @@ func (b *Buffer) saveToFile(filename string, withSudo bool, autoSave bool) error
}
}
// Update the last time this file was updated after saving
defer func() {
b.ModTime, _ = util.GetModTime(filename)
err = b.Serialize()
}()
filename, err = util.ReplaceHome(filename)
if err != nil {
return err
@ -319,6 +313,8 @@ func (b *Buffer) saveToFile(filename string, withSudo bool, autoSave bool) error
if errors.Is(err, util.ErrOverwrite) {
screen.TermMessage(err)
err = errors.Unwrap(err)
b.UpdateModTime()
}
return err
}
@ -335,7 +331,10 @@ func (b *Buffer) saveToFile(filename string, withSudo bool, autoSave bool) error
b.Path = filename
b.AbsPath = absFilename
b.isModified = false
b.UpdateModTime()
b.ReloadSettings(true)
err = b.Serialize()
return err
}