From 35913b95befe84fae777c913995c30a626274991 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 3 Nov 2020 18:37:50 +0600 Subject: [PATCH] fixes in pagintion --- CHANGELOG.md | 3 +++ .../inmo/micro_utils/pagination/utils/IterableExtensions.kt | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3038b834379..5073a7fa383 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## 0.2.6 +* `Pagination` + * Fixes in function `List#paginate` + ## 0.2.5 * `Coroutines` diff --git a/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/utils/IterableExtensions.kt b/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/utils/IterableExtensions.kt index 4b6a5d97240..f6e631646fe 100644 --- a/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/utils/IterableExtensions.kt +++ b/pagination/common/src/commonMain/kotlin/dev/inmo/micro_utils/pagination/utils/IterableExtensions.kt @@ -21,7 +21,7 @@ fun Iterable.paginate(with: Pagination): PaginationResult { } fun List.paginate(with: Pagination): PaginationResult { - return subList(with.firstIndex, with.lastIndex + 1).createPaginationResult( + return subList(maxOf(with.firstIndex, 0), (minOf(with.lastIndex, lastIndex)) + 1).createPaginationResult( with, size.toLong() )