Repository navigation
Conversation
Scroll with EdgeDraggingAutoScroller while the pointer is held near the top or bottom, measuring the bottom edge from scrollBottomInset when something covers it. Reveal the drag's moving end even with showCursor: false, refresh the selection overlay when no keyboard is showing, and end a drag the system cancels.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Selecting text by dragging with a mouse or trackpad scrolls the editor when the pointer passes the top of the viewport, but not when it passes the bottom. You can extend a selection upwards through a long document, but a selection dragged downwards stops at the last visible line.
RenderEditor.extendSelectionkeeps base and extent in document order (base ≤ extent) whichever way the drag goes. While dragging,_showCaretOnScreenasksgetOffsetToRevealCursorwhich endpoint to reveal. For a non-collapsed selection that isn't aDragTextSelection, it revealsendpoints.first, the top of the selection. On an upward drag that's the end under the pointer, so the editor scrolls. On a downward drag it's where the drag started, which is already on screen, so the editor never scrolls.Selection-handle drags don't have this problem because they produce a
DragTextSelection, whosefirstflag says which end is moving.Fix:
extendSelectionnow produces aDragTextSelectiontoo, withfirst: truewhen the selection grows upwards (the base moved) andfirst: falsewhen it grows downwards (the extent moved).getOffsetToRevealCursorthen reveals the moving end. Upward drags behave as before.We hit this on an iPad with a Magic Keyboard trackpad: in a long note, a user could select upwards through the whole note but not downwards.
Follow-up: scrolling while the pointer is held at an edge
Testing that fix on the iPad turned up more problems with the same drag:
EdgeDraggingAutoScroller, asSelectableRegiondoes: while the pointer is within 24 px of the top or bottom edge, the editor keeps scrolling and extending the selection until the button is released.scrollBottomInset, the setting that already keeps the caret above such an overlay.showCursor: false(e.g. a read-only editor)._showCaretOnScreenreturns early when the cursor is hidden, so the drag never revealed its moving end. A drag now reveals it whatevershowCursoris._didChangeTextEditingValuenow refreshes the overlay after the build when no keyboard is showing, too.Tests
Added regression tests to
test/bug_fix_test.dart:scrollBottomInset: 60must keep scrolling. Without the inset handling it never starts.The full suite passes.
Type of Change