Fix buffer.RuneAt (#1895)

Fix buffer.RuneAt returning the rune not at the given location (as the
documentation claims) but just before it.
This commit is contained in:
Dmitry Maluka
2020-10-20 02:36:14 +02:00
committed by GitHub
parent 23162f7a34
commit 298fa40f90
3 changed files with 5 additions and 4 deletions

View File

@@ -109,7 +109,7 @@ func (b *Buffer) saveToFile(filename string, withSudo bool) error {
if b.Settings["eofnewline"].(bool) {
end := b.End()
if b.RuneAt(Loc{end.X, end.Y}) != '\n' {
if b.RuneAt(Loc{end.X - 1, end.Y}) != '\n' {
b.insert(end, []byte{'\n'})
}
}