mirror of
https://github.com/charmbracelet/glow.git
synced 2026-08-21 15:44:17 +02:00
Keep selection in-bounds when paginating
This commit is contained in:
parent
211e66c738
commit
531645e73e
1 changed files with 6 additions and 0 deletions
|
|
@ -177,6 +177,12 @@ func stashUpdate(msg boba.Msg, m stashModel) (stashModel, boba.Cmd) {
|
|||
if m.state == stashStateStashLoaded {
|
||||
m.paginator, cmd = paginator.Update(msg, m.paginator)
|
||||
cmds = append(cmds, cmd)
|
||||
|
||||
// Keep the index in bounds when paginating
|
||||
itemsOnPage := m.paginator.ItemsOnPage(len(m.documents))
|
||||
if m.index > itemsOnPage-1 {
|
||||
m.index = itemsOnPage - 1
|
||||
}
|
||||
}
|
||||
|
||||
return m, boba.Batch(cmds...)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue