terminal: Add ctrl+click link detection with mouse movement#42526
terminal: Add ctrl+click link detection with mouse movement#42526probably-neb merged 12 commits intozed-industries:mainfrom
Conversation
|
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'. |
This comment has been minimized.
This comment has been minimized.
|
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'. |
This comment has been minimized.
This comment has been minimized.
|
The cla-bot has been summoned, and re-checked this pull request! |
This comment has been minimized.
This comment has been minimized.
|
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? |
davewa
left a comment
There was a problem hiding this comment.
Thanks for doing this work! I thought of a couple more changes that I think will improve/simplify this. Also, I think some of the comments just repeat the code, I'd prefer those be removed. Otherwise, looks good.
davewa
left a comment
There was a problem hiding this comment.
Also, I'd love to see a couple unit tests for this using VisualTestContext::simulate_event() 😎
davewa
left a comment
There was a problem hiding this comment.
You may have figured out that my review style is iterative. I hope you are having as much fun as I am, it is shaping up nicely! I noticed that the use of FindHyperlink here results in us always calling find_from_grid_point twice in a row on the same position, I added a suggestion there.
|
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! |
Track hyperlink on mouse down and verify same link on mouse up, allowing ctrl+click to work even with slight mouse movement. Closes zed-industries#41994
Fix rustfmt violations in terminal ctrl+click implementation
- Remove redundant mouse_down_link field and OSC-8 handler - Simplify bounds check to use .contains() - Unify all clickable elements through find_from_grid_point()
- Rename mouse_down_detected_element to mouse_down_hyperlink - Change type to Option<(String, bool, Match)> to match find_from_grid_point - Simplify overlap check to equality comparison - Remove comments
c7ca729 to
db5f209
Compare
db5f209 to
35bacb9
Compare
35bacb9 to
8bd09ac
Compare
|
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... |
davewa
left a comment
There was a problem hiding this comment.
Looking really nice. I just added a few more comments, we're very close now 😎.
davewa
left a comment
There was a problem hiding this comment.
One last improvement, then I'd say this is ready!
|
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 |
|
@davewa It's still working stillworking.webm |
|
Yeah, it's working for me too now... I must have done something dumb earlier... 🤷♂️ |
|
@probably-neb It's ready |
|
Hey sorry for the delay. This got buried in my notifications inbox. I've merged main and will merge this PR once CI is green. Thanks for the great work @nihalxkumar! |
|
Thanks for fixing this. |
Closes #41994
This PR introduces Element-bounded drag tolerance for Ctrl/Cmd+click in terminal.
Previously, Ctrl/Cmd+click on terminal links required pixel-perfect accuracy. Any mouse movement during the click would cancel the navigation, making it frustrating to click on links, especially on high-DPI displays or with sensitive mice.
Users can now click anywhere within a clickable element (file path, URL, hyperlink), drag the cursor anywhere within that same element's boundaries and release to trigger navigation
Implementation:
textandgrid_range) on Ctrl/Cmd+mouse-downfind_from_grid_point()for element detectionBefore:
before.webm
After:
stillworking.webm
Release Notes:
ctrl|cmd+clickon links was very sensitive to mouse movement. Clicking links now tolerates mouse movement within the same clickable element, making link navigation more reliable