Skip to content

Commit

Permalink
fix: write to a different file
Browse files Browse the repository at this point in the history
  • Loading branch information
hizkifw committed Sep 20, 2024
1 parent dedc2e2 commit 430effb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion internal/display/key_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,20 @@ func handleCommand(m Model, command string, args []string) (Model, tea.Cmd) {
case "w", "write", "wq":
// Save the buffer
fileName := m.eb.Name
overwrite := true
if len(args) > 0 {
fileName = args[0]
overwrite = false
}

saveCmd := func() tea.Msg {
n, err := m.eb.Save(fileName)
var n int64
var err error
if overwrite {
n, err = m.eb.Save(fileName)
} else {
n, err = m.eb.WriteToFile(fileName)
}
if err != nil {
return StatusTextMsg{Text: "Error saving: " + err.Error(), Error: true}
}
Expand Down

0 comments on commit 430effb

Please sign in to comment.