From 570279a8481fe227f1fd44a0f2a9a5e783892320 Mon Sep 17 00:00:00 2001 From: Core Date: Thu, 5 Sep 2019 03:19:53 +0700 Subject: [PATCH] Fix deleting Thai vowel bug on iOS (skip string range sanitization) (flutter/engine#11807) --- .../darwin/ios/framework/Source/FlutterTextInputPlugin.mm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index 345f8de1cf..ad39e710ee 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -634,17 +634,19 @@ static UIReturnKeyType ToUIReturnKeyType(NSString* inputType) { // because it is the expected behavior of Thai input. // https://github.com/flutter/flutter/issues/24203 // https://github.com/flutter/flutter/issues/21745 + // https://github.com/flutter/flutter/issues/39399 // // This is needed for correct handling of the deletion of Thai vowel input. // TODO(cbracken): Get a good understanding of expected behavior of Thai // input and ensure that this is the correct solution. // https://github.com/flutter/flutter/issues/28962 if (_selectedTextRange.isEmpty && [self hasText]) { - NSRange oldRange = ((FlutterTextRange*)_selectedTextRange).range; + UITextRange* oldSelectedRange = _selectedTextRange; + NSRange oldRange = ((FlutterTextRange*)oldSelectedRange).range; if (oldRange.location > 0) { NSRange newRange = NSMakeRange(oldRange.location - 1, 1); - [self setSelectedTextRange:[FlutterTextRange rangeWithNSRange:newRange] - updateEditingState:false]; + _selectedTextRange = [[FlutterTextRange rangeWithNSRange:newRange] copy]; + [oldSelectedRange release]; } }