Clamp iOS selection to 0 < pos < length (flutter/engine#3636)

This commit is contained in:
Chris Bracken
2017-04-27 16:04:30 -07:00
committed by GitHub
parent 15e0d127bd
commit f0f09665d3

View File

@@ -169,8 +169,8 @@ static UIKeyboardType ToUIKeyboardType(NSString* inputType) {
NSInteger selectionBase = [state[@"selectionBase"] intValue];
NSInteger selectionExtent = [state[@"selectionExtent"] intValue];
NSUInteger start = MAX(0, MIN(selectionBase, selectionExtent));
NSUInteger end = MAX(0, MAX(selectionBase, selectionExtent));
NSUInteger start = MIN(MAX(0, MIN(selectionBase, selectionExtent)), (NSInteger)self.text.length);
NSUInteger end = MIN(MAX(0, MAX(selectionBase, selectionExtent)), (NSInteger)self.text.length);
NSRange selectedRange = NSMakeRange(start, end - start);
[self setSelectedTextRange:[FlutterTextRange rangeWithNSRange:selectedRange]
updateEditingState:NO];