Fix mouse caret positioning and gutter selection with word wrap#114
Conversation
MousePositionToOffset now uses the wrap map when WordWrap is true, correctly resolving visual rows to the right document line segment. Previously it used GetVisibleLineNumbers which maps rows 1:1 to document lines, ignoring that a single line may span multiple visual rows when wrapped. Adds BuildVisualLineForSegment for lightweight offset hit-testing without drawing attributes, and three integration tests covering clicks on wrapped rows, past-segment-end snapping, and first-row clicks with wrap enabled. Agent-Logs-Url: https://github.com/gui-cs/Editor/sessions/681b65ff-92f8-4c48-b849-4da7193f8690 Co-authored-by: tig <585482+tig@users.noreply.github.com>
|
@copilot selectkion using line numbers is still not right. again, ensure there are tests that fail before fixing. |
ViewRowToLineNumber now uses the wrap map when WordWrap is enabled, correctly resolving visual rows (including wrap-continuation rows) to the right document line number. Previously it used GetVisibleLineNumbers which maps rows 1:1 to document lines, causing gutter clicks on continuation rows to select the wrong line. LineNumberGutter.OnDrawingContent also updated to use the wrap-aware ViewRowToLineNumber and show blank for continuation rows instead of repeating (or showing wrong) line numbers. Two new tests: gutter click on wrap-continuation row, and gutter drag across wrapped rows. Agent-Logs-Url: https://github.com/gui-cs/Editor/sessions/87e391ef-f643-4b93-a072-52b1f23725ee Co-authored-by: tig <585482+tig@users.noreply.github.com>
…ant ViewRowToLineNumber call Agent-Logs-Url: https://github.com/gui-cs/Editor/sessions/87e391ef-f643-4b93-a072-52b1f23725ee Co-authored-by: tig <585482+tig@users.noreply.github.com>
Fixed in c0fce33. Added two tests that fail before the fix:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3bf3b10346
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@copilot see CR feedback and address as appropriate. |
Address CR feedback: LineNumberGutter.OnDrawingContent now uses IsViewRowFirstWrapSegment (checks WrapMapEntry.SegmentIndex == 0) instead of comparing with the previous row's line number. The old approach failed when the viewport was scrolled so row 0 was a continuation segment, because prevLineNumber started at -1. Also adds GetTotalVisualRows for correct past-end-of-document blank detection, and a new integration test verifying gutter rendering shows blank for continuation rows. Agent-Logs-Url: https://github.com/gui-cs/Editor/sessions/3215bcaf-60b9-4a9d-9a41-17efadb6b671 Co-authored-by: tig <585482+tig@users.noreply.github.com>
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Addressed in 5c870be. The Codex CR identified that Fix: Added |
MousePositionToOffsetinEditor.Mouse.csto use the wrap map whenWordWrapis enabledBuildVisualLineForSegmentfor lightweight offset hit-testing of wrap segmentsViewRowToLineNumberto use wrap map whenWordWrapis enabledLineNumberGutter.OnDrawingContentto render correctly with word wrap (blank for continuation rows)WrapMapEntry.SegmentIndexfor continuation detection instead ofprevLineNumbercomparison (fixes scrolled-to-continuation edge case)IsViewRowFirstWrapSegmentandGetTotalVisualRowshelpers