]> git.lizzy.rs Git - micro.git/commitdiff
line_array insert for eofnewline and make default
authorZachary Yedidia <zyedidia@gmail.com>
Tue, 25 Feb 2020 03:31:05 +0000 (22:31 -0500)
committerZachary Yedidia <zyedidia@gmail.com>
Tue, 25 Feb 2020 03:31:05 +0000 (22:31 -0500)
Makes the `eofnewline` option enabled by default.

Fixes #1525

internal/buffer/save.go
internal/config/settings.go
runtime/help/options.md

index 74b890ebbddaca4a225fd9505056f6f5ff44f8b8..6f07ea6c8b6b923a6558986b73872ee7bfc765b7 100644 (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'})
                }
        }
 
index 81c431d896157323cd98f5ee8911c5705f6955b4..5f5694e2d583b73b6010aef3a21320053201c71f 100644 (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",
index 709bd5da7b2fdedcfd4b8916b50533fe7b5ffd13..8b118380e71d7c265ca7ca1e192d54677fff3a31 100644 (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