Composer: lock down click-past-EOL behaviour with visual-row assertion#18
Open
MagMueller wants to merge 3 commits into
Open
Composer: lock down click-past-EOL behaviour with visual-row assertion#18MagMueller wants to merge 3 commits into
MagMueller wants to merge 3 commits into
Conversation
Bug: clicking past the visible end of a line in the composer placed the cursor on a LATER visual row of the same wrapped logical line, at an offset proportional to how far past the end the user clicked. Fix Composer::set_cursor_from_wrapped_position: compute the visible range of the clicked visual row and clamp the click column to it. For non-last visual rows of a wrapped logical line, clamp one position earlier — position == row_end is *visually* the start of the next wrapped row (no character separates soft-wrapped rows), so without this the cursor still rendered one row down. Last-visual-row clamps to line_len so end-of-line clicks land before the trailing \n, which renders correctly. Adds click_past_end_of_line_clips_to_that_line_end regression test covering both plain multi-line and wrapped cases.
…-line plain repro
7a7efe0 to
307916f
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.
Tightens the existing test so it asserts the visual row the cursor renders on, not just the byte position. Adds a second test mirroring the multi-line plain text case (logical lines separated by Shift+Enter newlines) where clicking past end of a line must stay on the clicked row.
These now serve as the regression contract for the cursor-jumping-to-next-line bug.
🤖 Generated with Claude Code
Summary by cubic
Fixes click-past-EOL in the composer by clamping clicks to the end of the clicked visual row so the cursor renders on that row, including soft-wrapped lines; last visual rows clamp to line length. Adds regression tests for wrapped and multi-line plain text to lock this behavior.
Written for commit 307916f. Summary will update on new commits.