Skip to content

Commit 3f16fc1

Browse files
authored
Merge pull request #1078 from wordpress-mobile/fix/20481-charoutofbounds
Catches IndexOutOfBoundsException occurring on edge cases
2 parents 6e9814f + 2a6f765 commit 3f16fc1

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

aztec/src/main/kotlin/org/wordpress/aztec/watchers/SuggestionWatcher.kt

+12-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,18 @@ class SuggestionWatcher(aztecText: AztecText) : TextWatcher {
143143
private fun reapplyCarriedOverInlineSpans(editableText: Spannable) {
144144
carryOverSpans.forEach {
145145
if (it.start >= 0 && it.end <= editableText.length && it.start < it.end) {
146-
editableText.setSpan(it.span, it.start, it.end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
146+
try {
147+
editableText.setSpan(
148+
it.span,
149+
it.start,
150+
it.end,
151+
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
152+
)
153+
} catch (e: IndexOutOfBoundsException) {
154+
// This is a workaround for a possible bug in the Android framework
155+
// https://github.com/wordpress-mobile/WordPress-Android/issues/20481
156+
e.printStackTrace()
157+
}
147158
}
148159
}
149160
}

0 commit comments

Comments
 (0)