mirror of
https://github.com/charmbracelet/glow
synced 2024-11-10 14:14:17 +00: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…
Reference in a new issue