diff --git a/pkg/math/math.go b/pkg/math/math.go index 56ff8d0..117b63f 100644 --- a/pkg/math/math.go +++ b/pkg/math/math.go @@ -43,7 +43,11 @@ func PagerBox(first, last uint64, pos, count int64) (uint64, int64) { var start uint64 if pos >= 0 { - start = first + uint64(pos) + if int64(first) > pos { + start = first + } else { + start = uint64(pos) + 1 + } } else { start = uint64(int64(last) + pos + 1) } diff --git a/pkg/math/math_test.go b/pkg/math/math_test.go index 2ae1d90..106951c 100644 --- a/pkg/math/math_test.go +++ b/pkg/math/math_test.go @@ -76,6 +76,8 @@ func TestPagerBox(t *testing.T) { {1, 10, 10, 10, 0, 0}, {1, 10, 0, es.AllEvents, 1, 10}, {1, 10, -1, -es.AllEvents, 10, -10}, + + {5, 10, 0, 1, 5, 1}, } for _, tt := range tests {