Fix fileformat for newly created files

Fixes #1575
This commit is contained in:
Zachary Yedidia
2020-06-06 15:56:13 -04:00
parent 07860b8973
commit 466889f540
4 changed files with 25 additions and 6 deletions

View File

@@ -297,7 +297,21 @@ func NewBuffer(r io.Reader, size int64, path string, startcursor Loc, btype BufT
if !hasBackup {
reader := bufio.NewReader(transform.NewReader(r, enc.NewDecoder()))
b.LineArray = NewLineArray(uint64(size), FFAuto, reader)
var ff FileFormat = FFAuto
if size == 0 {
// for empty files, use the fileformat setting instead of
// autodetection
switch b.Settings["fileformat"] {
case "unix":
ff = FFUnix
case "dos":
ff = FFDos
}
}
b.LineArray = NewLineArray(uint64(size), ff, reader)
}
b.EventHandler = NewEventHandler(b.SharedBuffer, b.cursors)