mirror of
https://github.com/Maks1mS/bubbles.git
synced 2025-10-30 21:37:13 +03:00
Fix panic in paginator when setting total items to zero
This commit is contained in:
@@ -53,6 +53,9 @@ func (m *Model) SetTotalPages(items int) int {
|
|||||||
// ItemsOnPage is a helper function for returning the numer of items on the
|
// ItemsOnPage is a helper function for returning the numer of items on the
|
||||||
// current page given the total numer of items passed as an argument.
|
// current page given the total numer of items passed as an argument.
|
||||||
func (m Model) ItemsOnPage(totalItems int) int {
|
func (m Model) ItemsOnPage(totalItems int) int {
|
||||||
|
if totalItems < 1 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
start, end := m.GetSliceBounds(totalItems)
|
start, end := m.GetSliceBounds(totalItems)
|
||||||
return end - start
|
return end - start
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user