File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -278,7 +278,12 @@ - (BOOL)textInputShouldChangeTextInRange:(NSRange)range replacementText:(NSStrin
278278
279279 NSString *previousText = [_predictedText substringWithRange: range] ?: @" " ;
280280
281- if (_predictedText) {
281+ // After clearing the text by replacing it with an empty string, `_predictedText`
282+ // still preserves the deleted text.
283+ // As the first character in the TextInput always comes with the range value (0, 0),
284+ // we should check the range value in order to avoid appending a character to the deleted string
285+ // (which caused the issue #18374)
286+ if (!NSEqualRanges (range, NSMakeRange (0 , 0 )) && _predictedText) {
282287 _predictedText = [_predictedText stringByReplacingCharactersInRange: range withString: text];
283288 } else {
284289 _predictedText = text;
You can’t perform that action at this time.
0 commit comments