wordpress-mobile / AztecEditor-Android

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

Make setSelection safe #1062

Open planarvoid opened 6 months ago

planarvoid commented 6 months 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: