Fix TextBoxWidget cursor drifting left when deleting overflowed single-line text#29
Open
cytoph wants to merge 1 commit into
Open
Fix TextBoxWidget cursor drifting left when deleting overflowed single-line text#29cytoph wants to merge 1 commit into
cytoph wants to merge 1 commit into
Conversation
Author
|
@microsoft-github-policy-service agree |
fef83bd to
1b01cb7
Compare
…single-line input When text overflows the viewport and the cursor is at the end, backspacing caused the cursor to drift left instead of staying pinned at the right edge. Added a rule in RenderSingleLine: when the cursor is at the end of the line and _horizontalOffset is greater than what's needed to keep the cursor at the right edge, clamp it down so the cursor stays pinned there. Added a regression test covering the delete-from-overflow case.
1b01cb7 to
6a74c19
Compare
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.
Summary
When a single-line
TextBoxWidgetcontains text that overflows the viewport and the cursor is at the end, pressing Backspace caused the cursor to visually drift left rather than staying pinned at the right edge. After several deletions the cursor ends up in the middle of the visible area, making it impossible to tell whether content is still hidden to the left.Root cause:
_horizontalOffsetis only adjusted inRenderSingleLinewhen the cursor moves past a viewport boundary. When deletion moves the cursor one cell inward from the right edge, neither boundary condition fires, so the offset stays stale and the cursor appears one cell to the left.Fix
Added a third condition in
RenderSingleLine: when the cursor is at the end of the line and_horizontalOffsetis larger than needed to keep the cursor at the right edge, clamp it down.Test
Added
Should_Keep_Cursor_Pinned_At_Right_Edge_When_Deleting_From_Overflowed_TexttoTextBoxWidgetTests.TheRenderMethod. It renders overflowed text once to establish the scroll offset, deletes one character, renders again, and asserts the cursor is still at the right edge.All 334 existing tests continue to pass.