terminal: Add ctrl+click link detection with mouse movement
Added element-bounded drag tolerance for Ctrl/Cmd+click in terminal. Users can now click anywhere on a clickable element (file path, URL, hyperlink), drag across it, and release anywhere within the same element to trigger navigation.
Implementation:
- Added mouse_down_detected_element field to store detected element text and grid range
- On Ctrl/Cmd+mouse-down: detect clickable element using existing find_from_grid_point()
- During drag: preserve click state if cursor stays within element's character boundaries
- On mouse-up: verify same element detected, trigger navigation if match
Before:
After:
Release Notes:
- Ctrl/Cmd+click on links now tolerates mouse movement, allowing users to drag across clickable elements without losing click detection.
Closes #41994
We require contributors to sign our Contributor License Agreement, and we don't have @nihalxkumar on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.
@cla-bot check
We require contributors to sign our Contributor License Agreement, and we don't have @nihalxkumar on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.
The cla-bot has been summoned, and re-checked this pull request!
We require contributors to sign our Contributor License Agreement, and we don't have @nihalxkumar on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.
@cla-bot check
The cla-bot has been summoned, and re-checked this pull request!
Updated PR description
Great work! Tested it and it feels much better than before.
cc @davewa who has been doing a bunch of work in this area recently. How does the code look to you?
I really appreciate the reviews from you. Please keep them coming, they makes things better for everyone <3
Going to mark this as draft while you're addressing the review comments. Please request my review when you think this is ready @nihalxkumar!
the checks appear to be flaky
I'm only seeing tests you added failing. Are you referring to a different test flaking? Or just calling out that the tests you've added seem to be flaky?
I saw the Mac test failing on another PR. I am checking what needs to fixed here brb
Thinking about this more, it would be simpler, more dependable, and still give us the test coverage we are looking for here to have these tests just call Terminal::mouse_* methods directly...
In local testing, it doesn't seem to work anymore? One of our refactors must have regressed the feature... interesting...
I am limited by memory. I used to check every build before committing with cargo build -j 2
After 4242a75a162ad0a9809936ac04cc5a9df50c3c64 I only used to check the terminal crate, clippy and rustfmt.
Started a build now
Yeah, it's working for me too now... I must have done something dumb earlier... 🤷♂️
@probably-neb It's ready