Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit 0ecd24e

Browse files
authored
Merge pull request #386 from UnityTech/fix_ios_issue
Fix iOS issue.
2 parents 7b003ab + 0fe7f3a commit 0ecd24e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Runtime/Plugins/platform/ios/UIWidgetsTextInputPlugin.mm

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,10 @@ - (NSUInteger)incrementOffsetPosition:(NSUInteger)position {
425425

426426
- (UITextPosition*)positionFromPosition:(UITextPosition*)position offset:(NSInteger)offset {
427427
NSUInteger offsetPosition = ((UIWidgetsTextPosition*)position).index;
428+
NSInteger newLocation = (NSInteger)offsetPosition + offset;
429+
if (newLocation < 0 || newLocation > (NSInteger)self.text.length) {
430+
return nil;
431+
}
428432
if (offset >= 0) {
429433
for (NSInteger i = 0; i < offset && offsetPosition < self.text.length; ++i)
430434
offsetPosition = [self incrementOffsetPosition:offsetPosition];
@@ -552,8 +556,8 @@ - (void)updateEditingState {
552556
NSUInteger selectionBase = ((UIWidgetsTextPosition*)_selectedTextRange.start).index;
553557
NSUInteger selectionExtent = ((UIWidgetsTextPosition*)_selectedTextRange.end).index;
554558

555-
NSUInteger composingBase = 0;
556-
NSUInteger composingExtent = 0;
559+
NSUInteger composingBase = -1;
560+
NSUInteger composingExtent = -1;
557561
if (self.markedTextRange != nil) {
558562
composingBase = ((UIWidgetsTextPosition*)self.markedTextRange.start).index;
559563
composingExtent = ((UIWidgetsTextPosition*)self.markedTextRange.end).index;

0 commit comments

Comments
 (0)