line_array insert for eofnewline and make default

Makes the `eofnewline` option enabled by default.

Fixes #1525
This commit is contained in:
Zachary Yedidia 2020-02-24 22:31:05 -05:00
parent 25b9342fbe
commit d78fe81e21
3 changed files with 5 additions and 4 deletions

View File

@ -112,7 +112,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' {
b.Insert(end, "\n")
b.insert(end, []byte{'\n'})
}
}

View File

@ -191,7 +191,7 @@ var defaultCommonSettings = map[string]interface{}{
"cursorline": true,
"diffgutter": false,
"encoding": "utf-8",
"eofnewline": false,
"eofnewline": true,
"fastdirty": false,
"fileformat": "unix",
"filetype": "unknown",

View File

@ -85,9 +85,10 @@ Here are the available options:
default value: `utf-8`
* `eofnewline`: micro will automatically add a newline to the file.
* `eofnewline`: micro will automatically add a newline to the end of the
file if one does not exist.
default value: `false`
default value: `true`
* `fastdirty`: this determines what kind of algorithm micro uses to determine
if a buffer is modified or not. When `fastdirty` is on, micro just uses a