summaryrefslogtreecommitdiff
path: root/internal/ui/table.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-06-22 14:25:14 +0300
committerPaul Buetow <paul@buetow.org>2026-06-22 14:25:14 +0300
commita1407cd9c960da7cb7e13b37ec444590319b8908 (patch)
tree007b9f796e05c0043292afedb89c8b6c6f723bd0 /internal/ui/table.go
parent6fafae88fd8cfcb972c1ed98d8eb591a910043d2 (diff)
Fix description editor ExecProcess flow for nq0
Diffstat (limited to 'internal/ui/table.go')
-rw-r--r--internal/ui/table.go39
1 files changed, 23 insertions, 16 deletions
diff --git a/internal/ui/table.go b/internal/ui/table.go
index e629c20..59eaaeb 100644
--- a/internal/ui/table.go
+++ b/internal/ui/table.go
@@ -237,6 +237,10 @@ type descEditDoneMsg struct {
tempFile string
}
+type descEditLaunchMsg struct {
+ tempFile string
+}
+
type shellDoneMsg struct {
result task.RunResult
err error
@@ -320,7 +324,7 @@ func editCmd(id int) tea.Cmd {
return tea.ExecProcess(c, func(err error) tea.Msg { return editDoneMsg{err: err} })
}
-// editDescriptionCmd returns a command that opens the description in external editor
+// editDescriptionCmd returns a command that prepares the description temp file.
func editDescriptionCmd(description string) tea.Cmd {
return func() tea.Msg {
tmpPath, err := prepareDescriptionTempFile(description, func() (descriptionTempFile, error) {
@@ -330,23 +334,24 @@ func editDescriptionCmd(description string) tea.Cmd {
return descEditDoneMsg{err: err, tempFile: ""}
}
- // Get editor from environment
- editor := os.Getenv("EDITOR")
- if editor == "" {
- editor = "vi" // fallback to vi
- }
-
- // Create the command
- c := exec.Command(editor, tmpPath)
- c.Stdin = os.Stdin
- c.Stdout = os.Stdout
- c.Stderr = os.Stderr
+ return descEditLaunchMsg{tempFile: tmpPath}
+ }
+}
- // Use ExecProcess to properly handle the external TUI editor
- return tea.ExecProcess(c, func(err error) tea.Msg {
- return descEditDoneMsg{err: err, tempFile: tmpPath}
- })()
+func launchDescriptionEditorCmd(tmpPath string) tea.Cmd {
+ editor := os.Getenv("EDITOR")
+ if editor == "" {
+ editor = "vi"
}
+
+ c := exec.Command(editor, tmpPath)
+ c.Stdin = os.Stdin
+ c.Stdout = os.Stdout
+ c.Stderr = os.Stderr
+
+ return tea.ExecProcess(c, func(err error) tea.Msg {
+ return descEditDoneMsg{err: err, tempFile: tmpPath}
+ })
}
func blinkCmd() tea.Cmd {
@@ -608,6 +613,8 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m.handleWindowResize(msg)
case editDoneMsg:
return m.handleEditDone(msg)
+ case descEditLaunchMsg:
+ return m, launchDescriptionEditorCmd(msg.tempFile)
case descEditDoneMsg:
return m.handleDescEditDone(msg)
case shellDoneMsg: