Skip to content
Merged
Show file tree
Hide file tree
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
17 changes: 11 additions & 6 deletions internal/tui/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ type OpenFileMsg struct{ Path string }
type editorFinishedMsg struct{ err error }

// EditConfigMsg signals that the user wants to edit the config file.
type EditConfigMsg struct{}
// Visual selects $VISUAL (GUI editor) instead of $EDITOR (terminal editor).
type EditConfigMsg struct{ Visual bool }

// editorConfigFinishedMsg is sent when the config editor exits.
type editorConfigFinishedMsg struct{ err error }
Expand Down Expand Up @@ -197,7 +198,7 @@ func (m AppModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
targetPath = tmpFile.Name()
}

editor := resolveEditor()
editor := resolveEditor(msg.Visual)
c := exec.Command(editor, targetPath)
return m, tea.ExecProcess(c, func(err error) tea.Msg {
return editorConfigFinishedMsg{err}
Expand Down Expand Up @@ -338,10 +339,14 @@ func (m AppModel) listenLogEntries() tea.Cmd {
// Helpers
// ---------------------------------------------------------------------------

// resolveEditor returns the user's preferred editor: $VISUAL, $EDITOR, or "vi".
func resolveEditor() string {
if e := os.Getenv("VISUAL"); e != "" {
return e
// resolveEditor returns the user's preferred editor.
// When visual is true it checks $VISUAL first (GUI editor like BBEdit);
// otherwise it uses $EDITOR (terminal editor like Helix), falling back to "vi".
func resolveEditor(visual bool) string {
if visual {
if e := os.Getenv("VISUAL"); e != "" {
return e
}
}
if e := os.Getenv("EDITOR"); e != "" {
return e
Expand Down
4 changes: 3 additions & 1 deletion internal/tui/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ func (m DashboardModel) updateNormal(msg tea.KeyMsg) (DashboardModel, tea.Cmd) {
return m, func() tea.Msg { return OpenFileMsg{Path: path} }
case "e":
return m, func() tea.Msg { return EditConfigMsg{} }
case "E":
return m, func() tea.Msg { return EditConfigMsg{Visual: true} }
case "/":
m.filtering = true
m.filter = ""
Expand Down Expand Up @@ -376,7 +378,7 @@ func (m DashboardModel) View() string {
helpKey("↑↓") + helpDesc("navigate") +
helpKey("enter") + helpDesc("expand") +
helpKey("v") + helpDesc("view") +
helpKey("e") + helpDesc("config") +
helpKey("e/E") + helpDesc("config") +
helpKey("l") + helpDesc("logs") +
helpKey("/") + helpDesc("filter")
if m.filter != "" {
Expand Down
Loading