From 44f24bd9807f4883265a14bc4f7c67f3d0dc1164 Mon Sep 17 00:00:00 2001 From: stuartmorgan Date: Mon, 3 Feb 2020 15:22:44 -0800 Subject: [PATCH] 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 --- .../darwin/macos/framework/Source/FlutterTextInputPlugin.mm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/macos/framework/Source/FlutterTextInputPlugin.mm index 402534b662..46af8dd395 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterTextInputPlugin.mm @@ -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 } -- GitLab