diff options
author | Sergey Minakov <naithar@icloud.com> | 2021-04-30 11:40:12 +0300 |
---|---|---|
committer | Sergey Minakov <naithar@icloud.com> | 2021-04-30 11:44:32 +0300 |
commit | 275772818ddc6b03cee4b72435828dca01b291e8 (patch) | |
tree | 6d99f91180c0aeeda0250b3be885a91eb6fa7cef | |
parent | aa677865e3b335ee5f96e0c8c1a6bb1a54a66f58 (diff) |
[iOS] Nonnegative start index for virtual keyboard range
-rw-r--r-- | platform/iphone/keyboard_input_view.mm | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/platform/iphone/keyboard_input_view.mm b/platform/iphone/keyboard_input_view.mm index 1408f78e90..0e5a98a3e6 100644 --- a/platform/iphone/keyboard_input_view.mm +++ b/platform/iphone/keyboard_input_view.mm @@ -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; |