Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Correct handling for composed character ranges at text.length - #3590

Merged
cbracken merged 2 commits into
flutter-team-archive:masterfrom
cbracken:clear-crash-fix
Apr 13, 2017
Merged

cbracken merged 2 commits into
flutter-team-archive:masterfrom
cbracken:clear-crash-fix

Conversation

@cbracken

@cbracken cbracken commented Apr 13, 2017 •

Copy link
Copy Markdown
Contributor

Fixes a bug wherein a framework side update to the text could trigger a
crash.

Ensure that both self.text and self.selectedTextRange are updated before
triggering textDidChange: or selectionDidChange: on the input delegate
(which then re-computes positions). This prevents inconsistencies in
selection vs text position/offset lookups triggered by didChange
notifications.

Ensure that rangeOfComposedCharacterSequenceAtIndex: is only ever called
for index values > 0 && < self.text.length. This prevents such calls for
position with index == self.text.length.

Also reduces unnecessary textDidChange/selectionDidChange notifications:
replaceRange:withText: is only ever called by UIKit and methods called
by UIKit (insertText, deleteBackward), so notification is unnecessary.

@cbracken

cbracken commented Apr 13, 2017 •

Copy link
Copy Markdown
Contributor Author

Fixes flutter/flutter#9362

Will work with @yjbanov so we can get together driver tests and that provide text editing coverage both iOS and Android. Right now flutter_driver is missing some functionality necessary to deal directly with key events, but for testing IMEs, we're going to need this.

@cbracken cbracken changed the title Clear crash fix Correct handling for composed character ranges at text.length Apr 13, 2017
@cbracken

Copy link
Copy Markdown
Contributor Author

/cc @abarth @collinjackson

Fixes a bug wherein a framework side update to the text could trigger a
crash.

Ensure that both self.text and self.selectedTextRange are updated before
triggering textDidChange: or selectionDidChange: on the input delegate
(which then re-computes positions).

Ensure that rangeOfComposedCharacterSequenceAtIndex: is only ever called
for index values > 0 && < self.text.length. This prevents such calls for
position with index == self.text.length.
replaceRange:withText: and setMarkedText: are only ever called by UIKit
and methods called by UIKit (insertText, deleteBackward), so
notification is unnecessary.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Development

Successfully merging this pull request may close these issues.

3 participants