From cb36f1aba6b8005889de6090ddf36003564ccd6c Mon Sep 17 00:00:00 2001 From: Justin McCandless Date: Wed, 28 Nov 2018 09:05:04 -0800 Subject: [PATCH] Update marked text before selection so textInRange is never called with invalid input --- .../framework/Source/FlutterTextInputPlugin.mm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index 1e0bead42e5eb..0f7dc0a0d6812 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -216,6 +216,14 @@ - (void)setTextInputState:(NSDictionary*)state { [self.text setString:newText]; } + 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; + NSInteger selectionBase = [state[@"selectionBase"] intValue]; NSInteger selectionExtent = [state[@"selectionExtent"] intValue]; NSRange selectedRange = [self clampSelection:NSMakeRange(MIN(selectionBase, selectionExtent), @@ -233,14 +241,6 @@ - (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];