mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Fix delete of entire selection in macOS text input (flutter/engine#16276)
Fixes a bug where deleteBackward was checking for being at the start of the text before checking for a non-empty selection, breaking deletion when the entire text field was selected. Also removes an (incorrect) post-deletion position update that was redundant with code in insertText:replacementRange:, and thus having no effect. Fixes https://github.com/flutter/flutter/issues/46150
This commit is contained in:
parent
950eb2447f
commit
3d5bb2ac20
@ -181,15 +181,14 @@ static NSString* const kMultilineInputType = @"TextInputType.multiline";
|
||||
|
||||
- (void)deleteBackward:(id)sender {
|
||||
NSRange selection = self.activeModel.selectedRange;
|
||||
if (selection.location == 0)
|
||||
return;
|
||||
NSRange range = selection;
|
||||
if (selection.length == 0) {
|
||||
if (selection.location == 0)
|
||||
return;
|
||||
NSUInteger location = (selection.location == NSNotFound) ? self.activeModel.text.length - 1
|
||||
: selection.location - 1;
|
||||
range = NSMakeRange(location, 1);
|
||||
}
|
||||
self.activeModel.selectedRange = NSMakeRange(range.location, 0);
|
||||
[self insertText:@"" replacementRange:range]; // Updates edit state
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user