Skip to content

Commit

Permalink
fix(cli): open EDITOR correctly
Browse files Browse the repository at this point in the history
resolves #6019
  • Loading branch information
JanDeDobbeleer committed Dec 20, 2024
1 parent b4d0b42 commit 2fbffe6
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/cli/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,22 @@ func editFileWithEditor(file string) int {
return 1
}

var args []string
if strings.Contains(editor, " ") {
strs := strings.Split(editor, " ")
editor = strs[0]
args = strs[1:]
}
editor = strings.TrimSpace(editor)
args := strings.Split(editor, " ")

editor = args[0]
args = append(args[1:], file)

args = append(args, file)
cmd := exec.Command(editor, args...)

err := cmd.Run()
if err != nil {
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

if err := cmd.Run(); err != nil {
fmt.Println(err.Error())
return 1
}

return cmd.ProcessState.ExitCode()
return 0
}

0 comments on commit 2fbffe6

Please sign in to comment.