Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make setSelection safe #1062

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

planarvoid
Copy link
Contributor

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:

  • Preserve cursor position N at the end of text
  • Set the cursor position to 0
  • Do some modification to the text that shorten the text to N - 1
  • Try to set the cursor position to N
  • Crash because text length is N-1 < N

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:

  • 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.

@planarvoid planarvoid added the bug label Oct 10, 2023
@planarvoid planarvoid requested a review from danilo04 October 10, 2023 09:48
@planarvoid planarvoid self-assigned this Oct 10, 2023
@Bibazavr
Copy link

possible related to #848

@Bibazavr
Copy link

I've checked this solution and this fixes crash from #848

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants