fix: start position when first > 1

This commit is contained in:
Jon Lundy 2022-11-20 10:17:15 -07:00
parent 03df7902ad
commit 4baeb07cb7
Signed by untrusted user who does not match committer: xuu
GPG Key ID: C63E6D61F3035024
2 changed files with 7 additions and 1 deletions

View File

@ -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)
}

View File

@ -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 {