From 275772818ddc6b03cee4b72435828dca01b291e8 Mon Sep 17 00:00:00 2001 From: Sergey Minakov Date: Fri, 30 Apr 2021 11:40:12 +0300 Subject: [iOS] Nonnegative start index for virtual keyboard range --- platform/iphone/keyboard_input_view.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'platform/iphone') 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; -- cgit v1.2.3