Merge pull request #48323 from naithar/fix/ios-virtual-keyboard-range

[iOS] Nonnegative start index for virtual keyboard range
This commit is contained in:
Rémi Verschelde 2021-04-30 11:47:49 +02:00 committed by GitHub
commit a91effc791
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -88,13 +88,15 @@
self.text = existingString;
self.previousText = existingString;
NSInteger safeStartIndex = MAX(start, 0);
NSRange textRange;
// Either a simple cursor or a selection.
if (end > 0) {
textRange = NSMakeRange(start, end - start);
textRange = NSMakeRange(safeStartIndex, end - start);
} else {
textRange = NSMakeRange(start, 0);
textRange = NSMakeRange(safeStartIndex, 0);
}
self.selectedRange = textRange;