From 464c84bb13af916400e44a8746bb86dc9d810562 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Thu, 12 Nov 2020 21:59:33 -0500 Subject: [PATCH] Fix a regression where esc wouldn't clear filtered results --- ui/ui.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ui/ui.go b/ui/ui.go index ba23684..2908e2c 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -240,13 +240,23 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case "q", "esc": var cmd tea.Cmd - // Send these keys through to stash + // Send q/esc through to stash switch m.state { case stateShowStash: switch m.stash.state { + + // Send q/esc through in these cases case stashStateSettingNote, stashStatePromptDelete, - stashStateShowingError, stashStateSearchNotes: + stashStateShowingError, stashStateSearchNotes, + stashStateShowFiltered: + + // If we're fitering, only send esc through so we can clear + // the filter results. Q quits as normal. + if m.stash.state == stashStateShowFiltered && msg.String() == "q" { + return m, tea.Quit + } + m.stash, cmd = stashUpdate(msg, m.stash) return m, cmd }