Skip to content

Commit 9373ea6

Browse files
committed
fix: index out of bounds when calculate offset in Composition view
1 parent c484d7f commit 9373ea6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

app/src/main/java/com/osfans/trime/ime/composition/Composition.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ class Composition(context: Context, attrs: AttributeSet?) : TextView(context, at
383383
*/
384384
private fun calculateOffset(candidates: Array<CandidateListItem>): Int {
385385
if (candidates.isEmpty()) return 0
386-
var j = minOf(minCheckCount, candidates.size, maxCount) - 1
386+
var j = (minOf(minCheckCount, candidates.size, maxCount) - 1).coerceAtLeast(0)
387387
while (j > 0) {
388388
val text = candidates[j].text
389389
if (text.length >= minCheckLength) break

0 commit comments

Comments
 (0)