Skip to content

Commit 571f474

Browse files
authored
Update marked text before selection so textInRange is never called with (flutter#6989)
invalid input
1 parent daf0ede commit 571f474

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,14 @@ - (void)setTextInputState:(NSDictionary*)state {
216216
[self.text setString:newText];
217217
}
218218

219+
NSInteger composingBase = [state[@"composingBase"] intValue];
220+
NSInteger composingExtent = [state[@"composingExtent"] intValue];
221+
NSRange composingRange = [self clampSelection:NSMakeRange(MIN(composingBase, composingExtent),
222+
ABS(composingBase - composingExtent))
223+
forText:self.text];
224+
self.markedTextRange =
225+
composingRange.length > 0 ? [FlutterTextRange rangeWithNSRange:composingRange] : nil;
226+
219227
NSInteger selectionBase = [state[@"selectionBase"] intValue];
220228
NSInteger selectionExtent = [state[@"selectionExtent"] intValue];
221229
NSRange selectedRange = [self clampSelection:NSMakeRange(MIN(selectionBase, selectionExtent),
@@ -233,14 +241,6 @@ - (void)setTextInputState:(NSDictionary*)state {
233241
[self.inputDelegate selectionDidChange:self];
234242
}
235243

236-
NSInteger composingBase = [state[@"composingBase"] intValue];
237-
NSInteger composingExtent = [state[@"composingExtent"] intValue];
238-
NSRange composingRange = [self clampSelection:NSMakeRange(MIN(composingBase, composingExtent),
239-
ABS(composingBase - composingExtent))
240-
forText:self.text];
241-
self.markedTextRange =
242-
composingRange.length > 0 ? [FlutterTextRange rangeWithNSRange:composingRange] : nil;
243-
244244
if (textChanged) {
245245
[self.inputDelegate textDidChange:self];
246246

0 commit comments

Comments
 (0)