Skip to content

Commit

Permalink
fix: unrolled candidates size was still limited to about 144
Browse files Browse the repository at this point in the history
4e7247c reverts the last fix about this, my bad.
  • Loading branch information
WhiredPlanck committed Sep 2, 2024
1 parent 4e7247c commit b0eea1d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.osfans.trime.core.CandidateItem
import com.osfans.trime.daemon.RimeSession
import timber.log.Timber

class CandidatesPagingSource(val rime: RimeSession, val total: Int, val offset: Int) :
class CandidatesPagingSource(val rime: RimeSession, val offset: Int) :
PagingSource<Int, CandidateItem>() {
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, CandidateItem> {
// use candidate index for key, null means load from beginning (including offset)
Expand All @@ -22,12 +22,7 @@ class CandidatesPagingSource(val rime: RimeSession, val total: Int, val offset:
getCandidates(startIndex, pageSize)
}
val prevKey = if (startIndex >= pageSize) startIndex - pageSize else null
val nextKey =
if (total > 0) {
if (startIndex + pageSize + 1 >= total) null else startIndex + pageSize
} else {
if (candidates.size < pageSize) null else startIndex + pageSize
}
val nextKey = if (candidates.size < pageSize) null else startIndex + pageSize
return LoadResult.Page(candidates.toList(), prevKey, nextKey)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ abstract class BaseUnrolledCandidateWindow(
Pager(PagingConfig(pageSize = 48)) {
CandidatesPagingSource(
rime,
total = compactCandidate.adapter.run { before + itemCount },
offset = adapter.offset,
)
}
Expand Down

0 comments on commit b0eea1d

Please sign in to comment.