mirror of
https://github.com/charmbracelet/glow
synced 2024-11-10 14:14:17 +00:00
Fix bug where user couldn't exit pager in various stash-related states
This commit is contained in:
parent
cdc55a4b28
commit
60b1d6a6df
1 changed files with 12 additions and 11 deletions
23
ui/ui.go
23
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...)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue