fix RichTextField text delete

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-06-17 18:03:32 +08:00
parent 3510b6c74d
commit fe2ebebfdd
2 changed files with 11 additions and 2 deletions

View File

@@ -657,6 +657,9 @@ class RichTextEditingController extends TextEditingController {
}
case TextEditingDeltaNonTextUpdate e:
if (!_isSelectionValid(e.selection, items.lastOrNull?.range.end ?? 0)) {
return;
}
newSelection = e.selection;
if (newSelection.isCollapsed) {
final newPos = dragOffset(newSelection.base);
@@ -689,6 +692,10 @@ class RichTextEditingController extends TextEditingController {
}
}
static bool _isSelectionValid(TextSelection selection, int length) {
return selection.start <= length && selection.end <= length;
}
TextStyle? composingStyle;
TextStyle? richStyle;