Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): open EDITOR correctly #6040

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Loading