From cac7eba5ea9cf15db027e2a5c73a3f9b3a4081a0 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Wed, 6 Dec 2017 11:30:14 -0800 Subject: [PATCH] Update the iOS mark region on setTextInputState (flutter/engine#4418) 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 --- .../darwin/ios/framework/Source/FlutterTextInputPlugin.mm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index f5e7de3067..86fb24e138 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -206,6 +206,14 @@ static UITextAutocapitalizationType ToUITextAutocapitalizationType(NSString* inp [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];