未验证 提交 033daf15 编写于 作者: C Chris Bracken 提交者: GitHub

Update the iOS mark region on setTextInputState (#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
上级 9b366e1e
......@@ -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];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册