@@ -6,7 +6,6 @@ import (
6 "math/rand"
6 "math/rand"
10 "path/filepath"
9 "path/filepath"
@@ -96,7 +95,7 @@ type OpenEditorMsg struct {
96func (m *editorCmp) openEditor(value string) tea.Cmd {
95func (m *editorCmp) openEditor(value string) tea.Cmd {
97 editor := os.Getenv("EDITOR")
96 editor := os.Getenv("EDITOR")
98 if editor == "" {
97 if editor == "" {
99− // Use platform-appropriate default editor
98+ // Use platform-appropriate default editor.
100 if runtime.GOOS == "windows" {
99 if runtime.GOOS == "windows" {
101 editor = "notepad"
100 editor = "notepad"
@@ -112,11 +111,11 @@ func (m *editorCmp) openEditor(value string) tea.Cmd {
112 if _, err := tmpfile.WriteString(value); err != nil {
111 if _, err := tmpfile.WriteString(value); err != nil {
113 return util.ReportError(err)
112 return util.ReportError(err)
115+ // Build the full shell command with the file argument.
115− c := exec.CommandContext(context.TODO(), editor, tmpfile.Name())
116+ cmdStr := fmt.Sprintf("%s %s", editor, tmpfile.Name())
116− c.Stdin = os.Stdin
117+
117− c.Stdout = os.Stdout
118− c.Stderr = os.Stderr
119− return tea.ExecProcess(c, func(err error) tea.Msg {
118+ return util.ExecShell(context.TODO(), cmdStr, func(err error) tea.Msg {
120 if err != nil {
119 if err != nil {
121 return util.ReportError(err)
120 return util.ReportError(err)