wordpress-mobile / AztecEditor-Android

A reusable native Android rich text editor component.
Mozilla Public License 2.0
673 stars 114 forks source link

Catches IndexOutOfBoundsException occurring on edge cases #1078

Closed antonis closed 1 month ago

antonis commented 1 month ago

Fixes https://github.com/wordpress-mobile/WordPress-Android/issues/20481

Related PRs:

Description

This PR adds exception handling for an IndexOutOfBoundsException thrown from the SpannableStringBuilder when the requested character position >= length on rare occasions.

Test

I did not find a way to reproduce the issue. Thus I suggest a sanity check like the following:

  1. Open the editor
  2. Apply some style
  3. Place the cursor inside the style span
  4. Accept a keyboard suggestion
  5. Verify that no crash occurs and that the style is applied after the text change

https://github.com/wordpress-mobile/AztecEditor-Android/assets/304044/0a1b1b4d-1425-4d1e-89db-7e3c9847980b

Make sure strings will be translated: