1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-03-25 22:01:14 +02:00

Update pkg/commands/oscommands/os.go

Co-authored-by: Ryoga <eial5q265e5+github@gmail.com>
This commit is contained in:
Luka Markušić 2022-08-03 13:57:26 +02:00 committed by GitHub
parent d56bb0b8ef
commit 64224e7caa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -120,17 +120,17 @@ func (c *OSCommand) AppendLineToFile(filename, line string) error {
return utils.WrapError(err)
}
buf := make([]byte, 1)
if info.Size() > 0 {
// read last char
buf := make([]byte, 1)
if _, err := f.ReadAt(buf, info.Size()-1); err != nil {
return utils.WrapError(err)
}
}
// if the last byte of the file is not a newline, add it
if []byte("\n")[0] != buf[0] {
_, err = f.WriteString("\n")
// if the last byte of the file is not a newline, add it
if []byte("\n")[0] != buf[0] {
_, err = f.WriteString("\n")
}
}
if err == nil {