fix: check text editing controlling, if selection is valid (#10868)

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou
2025-02-21 11:00:19 +08:00
committed by GitHub
parent 2575e14811
commit fc396d2166

View File

@@ -3706,11 +3706,11 @@ Widget workaroundWindowBorder(BuildContext context, Widget child) {
);
}
void updateTextAndPreserveSelection(TextEditingController controller, String text) {
final preSelectionStart = controller.selection.start;
final preSelectionEnd = controller.selection.end;
void updateTextAndPreserveSelection(
TextEditingController controller, String text) {
// Only care about select all for now.
final isSelected = preSelectionEnd > preSelectionStart;
final isSelected = controller.selection.isValid &&
controller.selection.end > controller.selection.start;
// Set text will make the selection invalid.
controller.text = text;