mirror of
https://github.com/charmbracelet/glow.git
synced 2026-08-09 09:49:09 +02:00
There's always at least 1 page available in the paginator
Passing 0 to `paginator.SetTotalPages()` is ineffective as it won't alter the model (paginator needs at least 1 page) and therefore doesn't update the page count. Filtering can lead to 0 items in the stash view - in this case we still want to have a page available in the paginator - so we also have pass 1 to `setTotalPages()`.
This commit is contained in:
parent
7500d88e93
commit
aba133b7e6
1 changed files with 6 additions and 3 deletions
|
|
@ -133,10 +133,13 @@ func (m *stashModel) setSize(width, height int) {
|
|||
// Sets the total paginator pages according to the amount of markdowns for the
|
||||
// current state.
|
||||
func (m *stashModel) setTotalPages() {
|
||||
pages := len(m.getNotes())
|
||||
|
||||
m.paginator.PerPage = max(1, (m.terminalHeight-stashViewTopPadding-stashViewBottomPadding)/stashViewItemHeight)
|
||||
m.paginator.SetTotalPages(pages)
|
||||
|
||||
if pages := len(m.getNotes()); pages < 1 {
|
||||
m.paginator.SetTotalPages(1)
|
||||
} else {
|
||||
m.paginator.SetTotalPages(pages)
|
||||
}
|
||||
|
||||
// Make sure the page stays in bounds
|
||||
if m.paginator.Page >= m.paginator.TotalPages-1 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue