From fc396d2166154252366f2c22bdfa755f05c4bf8b Mon Sep 17 00:00:00 2001 From: fufesou <13586388+fufesou@users.noreply.github.com> Date: Fri, 21 Feb 2025 11:00:19 +0800 Subject: [PATCH] fix: check text editing controlling, if selection is valid (#10868) Signed-off-by: fufesou --- flutter/lib/common.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/flutter/lib/common.dart b/flutter/lib/common.dart index 777924c66..205f30a68 100644 --- a/flutter/lib/common.dart +++ b/flutter/lib/common.dart @@ -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;