Skip to content

Commit

Permalink
[iOS] Nonnegative start index for virtual keyboard range
Browse files Browse the repository at this point in the history
(cherry picked from commit 2757728)
  • Loading branch information
naithar authored and akien-mga committed Apr 30, 2021
1 parent 5a20cef commit f953555
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions platform/iphone/keyboard_input_view.mm
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,15 @@ - (BOOL)becomeFirstResponderWithString:(NSString *)existingString multiline:(BOO
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;
Expand Down

0 comments on commit f953555

Please sign in to comment.