Skip to content

text: Fix correct TextView selection when dragging back to the anchor line#2112

Merged
huacnlee merged 1 commit intolongbridge:mainfrom
suxiaoshao:fix-2111-textview-selection-anchor-line
Mar 6, 2026
Merged

text: Fix correct TextView selection when dragging back to the anchor line#2112
huacnlee merged 1 commit intolongbridge:mainfrom
suxiaoshao:fix-2111-textview-selection-anchor-line

Conversation

@suxiaoshao
Copy link
Contributor

@suxiaoshao suxiaoshao commented Mar 3, 2026

Closes #2111

Description

Fix TextView selection when dragging back to the original line after crossing another line. The selection helper now treats points within the same rendered line as a single-line selection, so the highlight stays bounded by the anchor and current cursor positions. This also adds regression tests for the same visual line with different y positions.

AI-generated portions reviewed for accuracy: the selection helper adjustment and the regression tests in crates/ui/src/text/inline.rs.

Screenshot

Before

2026-03-03.19.10.59.mov

After

2026-03-03.19.07.05.mov

How to Test

  1. Run cargo test -p gpui-component test_point_in_text_selection --lib.
  2. In a selectable TextView, start a selection on one line, drag to the next line, then move back to the original line.
  3. Verify the selection on the original line is bounded by the anchor position and the current cursor position instead of extending to the line end.

Checklist

  • I have read the CONTRIBUTING document and followed the guidelines.
  • Reviewed the changes in this PR and confirmed AI generated code (If any) is accurate.
  • Passed cargo run for story tests related to the changes.
  • Tested macOS, Windows and Linux platforms performance (if the change is platform-specific)

@huacnlee huacnlee changed the title fix: correct TextView selection when dragging back to the anchor line text: Fix correct TextView selection when dragging back to the anchor line Mar 6, 2026
@huacnlee huacnlee merged commit 35e3284 into longbridge:main Mar 6, 2026
3 checks passed
@huacnlee
Copy link
Member

huacnlee commented Mar 6, 2026

Thank you.

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.

TextView selection can expand to line end after dragging back to the anchor line

2 participants