Skip to content

Conversation

@antonis
Copy link
Contributor

@antonis antonis commented Mar 21, 2024

Fixes wordpress-mobile/WordPress-Android#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
Screen_recording_20240321_132332.mp4

Make sure strings will be translated:

  • If there are new strings that have to be translated, I have added them to the client's strings.xml as a part of the integration PR.

@antonis antonis added bug Gutenberg This issue is also valid importing Aztec in Gutenberg labels Mar 21, 2024
@antonis antonis requested a review from geriux March 21, 2024 11:28
Copy link

@geriux geriux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I've tested different test cases and the editor works as expected 🚀

It makes sense to go with this approach.

@antonis antonis merged commit 3f16fc1 into trunk Mar 22, 2024
@antonis antonis deleted the fix/20481-charoutofbounds branch March 22, 2024 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Gutenberg This issue is also valid importing Aztec in Gutenberg

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IndexOutOfBoundsException: charAt: X >= length X

3 participants