wordpress-mobile / AztecEditor-Android

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

Make setSelection safe #1062

Open planarvoid opened 1 year ago

planarvoid commented 1 year ago

Fix

We're having occasional issues when the setSelection is called out of bounds of the text. While it would be better to fix the underlying issues, I think this is a safe approach to handling this. What usually crashes the app is something like this:

This solution handles that case and if this happens, sets the selection to N-1 instead. I can't think of a case where this might be an issue but let me know if you think it's unsafe.

Review

@danilo04

Make sure strings will be translated:

Bibazavr commented 1 week ago

possible related to https://github.com/wordpress-mobile/AztecEditor-Android/issues/848

Bibazavr commented 1 week ago

I've checked this solution and this fixes crash from https://github.com/wordpress-mobile/AztecEditor-Android/issues/848