[iOS] Nonnegative start index for virtual keyboard range

(cherry picked from commit 275772818d)
This commit is contained in:
Sergey Minakov 2021-04-30 11:40:12 +03:00 committed by Rémi Verschelde
parent 5a20cef857
commit f9535554fa
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -87,13 +87,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;