fix: start position when first > 1
This commit is contained in:
parent
03df7902ad
commit
4baeb07cb7
|
@ -43,7 +43,11 @@ func PagerBox(first, last uint64, pos, count int64) (uint64, int64) {
|
||||||
var start uint64
|
var start uint64
|
||||||
|
|
||||||
if pos >= 0 {
|
if pos >= 0 {
|
||||||
start = first + uint64(pos)
|
if int64(first) > pos {
|
||||||
|
start = first
|
||||||
|
} else {
|
||||||
|
start = uint64(pos) + 1
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
start = uint64(int64(last) + pos + 1)
|
start = uint64(int64(last) + pos + 1)
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,8 @@ func TestPagerBox(t *testing.T) {
|
||||||
{1, 10, 10, 10, 0, 0},
|
{1, 10, 10, 10, 0, 0},
|
||||||
{1, 10, 0, es.AllEvents, 1, 10},
|
{1, 10, 0, es.AllEvents, 1, 10},
|
||||||
{1, 10, -1, -es.AllEvents, 10, -10},
|
{1, 10, -1, -es.AllEvents, 10, -10},
|
||||||
|
|
||||||
|
{5, 10, 0, 1, 5, 1},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user