From 7509a18af0e919ad8e26ef6e0c7002dd738b0894 Mon Sep 17 00:00:00 2001 From: Core Date: Sat, 31 Aug 2019 14:39:48 +0700 Subject: [PATCH 1/2] Modify deleteBackward logic to skip sanitizedRange calculation --- .../darwin/ios/framework/Source/FlutterTextInputPlugin.mm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index 345f8de1cfaf4..9301000fc1601 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -634,18 +634,20 @@ - (void)deleteBackward { // 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]; } if (!_selectedTextRange.isEmpty) From b5560348e5ecb5571f53c79100b84c7e8878f52c Mon Sep 17 00:00:00 2001 From: Core Date: Sat, 31 Aug 2019 15:06:47 +0700 Subject: [PATCH 2/2] Fix over release when selectedTextRange didn't change --- .../darwin/ios/framework/Source/FlutterTextInputPlugin.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index 9301000fc1601..ad39e710eeb50 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -646,8 +646,8 @@ - (void)deleteBackward { if (oldRange.location > 0) { NSRange newRange = NSMakeRange(oldRange.location - 1, 1); _selectedTextRange = [[FlutterTextRange rangeWithNSRange:newRange] copy]; + [oldSelectedRange release]; } - [oldSelectedRange release]; } if (!_selectedTextRange.isEmpty)