Skip to content

Commit

Permalink
Catches IndexOutOfBoundsException occurring on edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonis Lilis committed Mar 21, 2024
1 parent e204002 commit a93dd4e
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 a93dd4e

Please sign in to comment.