Skip to content

Commit a5b4923

Browse files
committed
Manually setting suggestions spans to guard against unexpected index issues.
1 parent d8a11ed commit a5b4923

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

aztec/src/main/kotlin/org/wordpress/aztec/SamsungInputConnection.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,15 @@ class SamsungInputConnection(
118118
if (newCursorPosition > editable.length) cursorPosition = editable.length
119119
Selection.setSelection(editable, cursorPosition)
120120

121-
TextUtils.copySpansFrom(text as Spanned, 0, text.length, SuggestionSpan::class.java, editable,
122-
composingSpanStart)
121+
(text as Spanned).getSpans(0, text.length, SuggestionSpan::class.java).forEach {
122+
val st: Int = text.getSpanStart(it)
123+
val en: Int = text.getSpanEnd(it)
124+
val fl: Int = text.getSpanFlags(it)
125+
126+
if (editable.length > composingSpanStart + en) {
127+
editable.setSpan(it, composingSpanStart + st, composingSpanStart + en, fl)
128+
}
129+
}
123130

124131
return true
125132
}

0 commit comments

Comments
 (0)