Fix bug that eofnewline does not work on save

This commit is contained in:
10sr
2016-12-15 16:27:10 +09:00
parent 2bc70890f0
commit 5b689a5592

View File

@@ -283,13 +283,13 @@ func (b *Buffer) SaveAs(filename string) error {
b.UpdateRules()
dir, _ := homedir.Dir()
b.Path = strings.Replace(filename, "~", dir, 1)
str := b.String()
if b.Settings["eofnewline"].(bool) {
end := b.End()
if b.RuneAt(Loc{end.X - 1, end.Y}) != '\n' {
b.Insert(end, "\n")
}
}
str := b.String()
data := []byte(str)
err := ioutil.WriteFile(filename, data, 0644)
if err == nil {