diff options
Diffstat (limited to 'menu')
| -rw-r--r-- | menu/model.go | 5 | ||||
| -rw-r--r-- | menu/target.go | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/menu/model.go b/menu/model.go index ceeb861..9d8fa82 100644 --- a/menu/model.go +++ b/menu/model.go @@ -11,6 +11,7 @@ type Model struct { Index int Indices map[int]model.HydratedTarget SourceIndices map[int]*model.HydratedSource + Quit bool } func (m *Model) Init() tea.Cmd { @@ -40,6 +41,7 @@ func (m *Model) HandleInput(msg tea.KeyMsg) (tea.Cmd, error) { case "down", "j": m.Index++ case "q", "esc": + m.Quit = true cmd = tea.Quit case "space", " ", "enter": cmd = tea.Quit @@ -59,6 +61,9 @@ func (m *Model) View() string { } func (m *Model) Result() (*model.HydratedSource, model.HydratedTarget) { + if m.Quit { + return nil, nil + } return m.SourceIndices[m.Index], m.Indices[m.Index] } diff --git a/menu/target.go b/menu/target.go index b17ed68..3323430 100644 --- a/menu/target.go +++ b/menu/target.go @@ -42,7 +42,7 @@ func (m *Model) Target(t model.HydratedTarget) string { selectionStyle := TargetStyle selectionDescriptionStyle := TargetDescriptionStyle _, sel := m.Result() - if sel.Target() == t.Target() { + if sel != nil && sel.Target() == t.Target() { selectionStyle = SelectedTargetStyle selectionDescriptionStyle = SelectedTargetDescriptionStyle } |
