mirror of
https://github.com/charmbracelet/glow.git
synced 2026-08-09 09:49:09 +02:00
Spilling over top/bottom in stash browser goes to the prev/next page
This commit is contained in:
parent
5d2ca090ac
commit
8ba5c1fa0d
1 changed files with 19 additions and 2 deletions
21
ui/stash.go
21
ui/stash.go
|
|
@ -120,13 +120,30 @@ func stashUpdate(msg boba.Msg, m stashModel) (stashModel, boba.Cmd) {
|
|||
case "k":
|
||||
fallthrough
|
||||
case "up":
|
||||
m.index = max(0, m.index-1)
|
||||
m.index--
|
||||
if m.index < 0 && m.paginator.Page == 0 {
|
||||
// Stop
|
||||
m.index = 0
|
||||
} else if m.index < 0 {
|
||||
// Go to previous page
|
||||
m.paginator.PrevPage()
|
||||
m.index = m.paginator.ItemsOnPage(len(m.documents)) - 1
|
||||
}
|
||||
return m, nil
|
||||
|
||||
case "j":
|
||||
fallthrough
|
||||
case "down":
|
||||
m.index = min(m.paginator.ItemsOnPage(len(m.documents))-1, m.index+1)
|
||||
itemsOnPage := m.paginator.ItemsOnPage(len(m.documents))
|
||||
m.index++
|
||||
if m.index >= itemsOnPage && m.paginator.OnLastPage() {
|
||||
// Stop
|
||||
m.index = itemsOnPage - 1
|
||||
} else if m.index >= itemsOnPage {
|
||||
// Go to next page
|
||||
m.index = 0
|
||||
m.paginator.NextPage()
|
||||
}
|
||||
return m, nil
|
||||
|
||||
case "enter":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue