Skip to content

Composer: lock down click-past-EOL behaviour with visual-row assertion#18

Open
MagMueller wants to merge 3 commits into
mainfrom
fix/click-test-update
Open

Composer: lock down click-past-EOL behaviour with visual-row assertion#18
MagMueller wants to merge 3 commits into
mainfrom
fix/click-test-update

Conversation

@MagMueller
Copy link
Copy Markdown
Contributor

@MagMueller MagMueller commented May 29, 2026

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.

Review in cubic

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.
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant