Skip to content

Commit

Permalink
Update the iOS mark region on setTextInputState (flutter#4418)
Browse files Browse the repository at this point in the history
Previously, we failed to clear/update the mark text range on updates
from the framework. This resulted in a crash if the incoming text value
was shorter than the current mark range when iOS attempts to extract the
mark range substring from the text.

Fixes flutter/flutter#12585
  • Loading branch information
cbracken authored Dec 6, 2017
1 parent 9b366e1 commit 033daf1
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,14 @@ - (void)setTextInputState:(NSDictionary*)state {
[self.inputDelegate selectionDidChange:self];
}

NSInteger composingBase = [state[@"composingBase"] intValue];
NSInteger composingExtent = [state[@"composingExtent"] intValue];
NSRange composingRange = [self clampSelection:NSMakeRange(MIN(composingBase, composingExtent),
ABS(composingBase - composingExtent))
forText:self.text];
self.markedTextRange =
composingRange.length > 0 ? [FlutterTextRange rangeWithNSRange:composingRange] : nil;

if (textChanged) {
[self.inputDelegate textDidChange:self];

Expand Down

0 comments on commit 033daf1

Please sign in to comment.