-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Currently it's not possible to select more text than it's visible in a scrollable. Because the function is always trying to show a padded caret rect, which for selected text happens to be at the beginning of the selection. This is because _FloatingCursorPainter.paint skips painting for non-collapsed selection and updating the cashed caret rect is performed at the end of the painting via callback to RenderEditable.
Visually there is no caret on non-collapsed selection, then what to show? Why should the beginning of the selection be treated as the caret position and not the end? Maybe the function should have another name and EditableTextState._currentCaretRect be updated to null . Or _currentCaretRect should be updated even for non-collapsed selection and placed at the extent of the selection.
Probably the simplest solution would be to add
final Rect rectToReveal;
final TextSelection selection = textEditingValue.selection;
if (selection.isCollapsed) {
rectToReveal = targetOffset.rect;
} else {
final List<Rect> selectionBoxes = renderEditable.getBoxesForSelection(selection);
rectToReveal = selection.baseOffset < selection.extentOffset ?
selectionBoxes.last : selectionBoxes.first;
}and change
rect: caretPadding.inflateRect(targetOffset.rect)to
rect: caretPadding.inflateRect(rectToReveal)Also note there is another issue with scrolling while selecting text by dragging the mouse, but that has to do with the implementation of TextSelectionGestureDetectorBuilder.onDragSelectionUpdate.