Skip to content

Commit

Permalink
Merge pull request #1078 from wordpress-mobile/fix/20481-charoutofbounds
Browse files Browse the repository at this point in the history
Catches IndexOutOfBoundsException occurring on edge cases
  • Loading branch information
antonis committed Mar 22, 2024
2 parents 6e9814f + 2a6f765 commit 3f16fc1
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,18 @@ class SuggestionWatcher(aztecText: AztecText) : TextWatcher {
private fun reapplyCarriedOverInlineSpans(editableText: Spannable) {
carryOverSpans.forEach {
if (it.start >= 0 && it.end <= editableText.length && it.start < it.end) {
editableText.setSpan(it.span, it.start, it.end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
try {
editableText.setSpan(
it.span,
it.start,
it.end,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
} catch (e: IndexOutOfBoundsException) {
// This is a workaround for a possible bug in the Android framework
// https://github.com/wordpress-mobile/WordPress-Android/issues/20481
e.printStackTrace()
}
}
}
}
Expand Down

0 comments on commit 3f16fc1

Please sign in to comment.