未验证 提交 44f24bd9 编写于 作者: S stuartmorgan 提交者: GitHub

Fix delete of entire selection in macOS text input (#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
上级 036ddbb0
......@@ -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
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册