Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deleting text when the last character is some special characters on IOS #7982

Merged
merged 12 commits into from
Mar 8, 2019
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,27 @@ - (void)insertText:(NSString*)text {

- (void)deleteBackward {
_selectionAffinity = _kTextAffinityDownstream;

// When deleting Thai vowel, _selectedTextRange has location
// but does not have length, so we have to manually set it.
// In addition, we needed to delete only a part of grapheme cluster
// because it is the expected behavior of Thai input.
// https://github.com/flutter/flutter/issues/24203
// https://github.com/flutter/flutter/issues/21745
//
// This is needed for correct handling of the deletion of Thai vowel input.
// TODO(cbracken): Get a good understanding of expected behaviour 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;
if (oldRange.location > 0) {
NSRange newRange = NSMakeRange(oldRange.location - 1, 1);
cbracken marked this conversation as resolved.
Show resolved Hide resolved
[self setSelectedTextRange:[FlutterTextRange rangeWithNSRange:newRange]
updateEditingState:false];
}
}

if (!_selectedTextRange.isEmpty)
[self replaceRange:_selectedTextRange withText:@""];
}
Expand Down