mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-09 09:22:48 +03:00
Update pkg/commands/oscommands/os.go
Co-authored-by: Ryoga <eial5q265e5+github@gmail.com>
This commit is contained in:
@@ -120,18 +120,18 @@ func (c *OSCommand) AppendLineToFile(filename, line string) error {
|
|||||||
return utils.WrapError(err)
|
return utils.WrapError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
buf := make([]byte, 1)
|
|
||||||
if info.Size() > 0 {
|
if info.Size() > 0 {
|
||||||
// read last char
|
// read last char
|
||||||
|
buf := make([]byte, 1)
|
||||||
if _, err := f.ReadAt(buf, info.Size()-1); err != nil {
|
if _, err := f.ReadAt(buf, info.Size()-1); err != nil {
|
||||||
return utils.WrapError(err)
|
return utils.WrapError(err)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// if the last byte of the file is not a newline, add it
|
// if the last byte of the file is not a newline, add it
|
||||||
if []byte("\n")[0] != buf[0] {
|
if []byte("\n")[0] != buf[0] {
|
||||||
_, err = f.WriteString("\n")
|
_, err = f.WriteString("\n")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
_, err = f.WriteString(line + "\n")
|
_, err = f.WriteString(line + "\n")
|
||||||
|
Reference in New Issue
Block a user