From 60b1d6a6df4a48e642737afe387ebedde232385f Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Mon, 24 Aug 2020 23:26:37 -0400 Subject: [PATCH] Fix bug where user couldn't exit pager in various stash-related states --- ui/ui.go | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/ui/ui.go b/ui/ui.go index 52251c6..f61ecaf 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -216,8 +216,17 @@ func update(msg tea.Msg, mdl tea.Model) (tea.Model, tea.Cmd) { case stateShowDocument: switch m.pager.state { - // If browsing, these keys have special cases - case pagerStateBrowse: + // If setting a note send all keys straight through + case pagerStateSetNote: + var batch []tea.Cmd + newPagerModel, cmd := pagerUpdate(msg, m.pager) + m.pager = newPagerModel + batch = append(batch, cmd) + return m, tea.Batch(batch...) + + // Otherwise let the user exit the view or application as + // normal. + default: switch msg.String() { case "q": return m, tea.Quit @@ -226,14 +235,6 @@ func update(msg tea.Msg, mdl tea.Model) (tea.Model, tea.Cmd) { batch = m.unloadDocument() return m, tea.Batch(batch...) } - - // If setting a note send all keys straight through - case pagerStateSetNote: - var batch []tea.Cmd - newPagerModel, cmd := pagerUpdate(msg, m.pager) - m.pager = newPagerModel - batch = append(batch, cmd) - return m, tea.Batch(batch...) } } @@ -241,7 +242,7 @@ func update(msg tea.Msg, mdl tea.Model) (tea.Model, tea.Cmd) { return m, tea.Quit case "left", "h", "delete": - if m.state == stateShowDocument && (m.pager.state == pagerStateBrowse || m.pager.state == pagerStateStatusMessage) { + if m.state == stateShowDocument && m.pager.state != pagerStateSetNote { cmds = append(cmds, m.unloadDocument()...) return m, tea.Batch(cmds...) }