zed icon indicating copy to clipboard operation
zed copied to clipboard

terminal: Add ctrl+click link detection with mouse movement

Open nihalxkumar opened this issue 1 month ago • 12 comments

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:

before.webm

After:

after.webm

Release Notes:

  • Ctrl/Cmd+click on links now tolerates mouse movement, allowing users to drag across clickable elements without losing click detection.

Closes #41994

nihalxkumar avatar Nov 12 '25 12:11 nihalxkumar

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[bot] avatar Nov 12 '25 12:11 cla-bot[bot]

@cla-bot check

nihalxkumar avatar Nov 12 '25 12:11 nihalxkumar

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[bot] avatar Nov 12 '25 12:11 cla-bot[bot]

The cla-bot has been summoned, and re-checked this pull request!

cla-bot[bot] avatar Nov 12 '25 12:11 cla-bot[bot]

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[bot] avatar Nov 12 '25 13:11 cla-bot[bot]

@cla-bot check

nihalxkumar avatar Nov 12 '25 13:11 nihalxkumar

The cla-bot has been summoned, and re-checked this pull request!

cla-bot[bot] avatar Nov 12 '25 13:11 cla-bot[bot]

Updated PR description

nihalxkumar avatar Nov 14 '25 13:11 nihalxkumar

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?

probably-neb avatar Nov 18 '25 15:11 probably-neb

I really appreciate the reviews from you. Please keep them coming, they makes things better for everyone <3

nihalxkumar avatar Nov 21 '25 16:11 nihalxkumar

Going to mark this as draft while you're addressing the review comments. Please request my review when you think this is ready @nihalxkumar!

probably-neb avatar Nov 21 '25 19:11 probably-neb

the checks appear to be flaky

nihalxkumar avatar Nov 22 '25 12:11 nihalxkumar

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?

probably-neb avatar Nov 24 '25 15:11 probably-neb

I saw the Mac test failing on another PR. I am checking what needs to fixed here brb

nihalxkumar avatar Nov 24 '25 16:11 nihalxkumar

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 avatar Nov 24 '25 16:11 davewa

In local testing, it doesn't seem to work anymore? One of our refactors must have regressed the feature... interesting...

davewa avatar Nov 25 '25 16:11 davewa

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

nihalxkumar avatar Nov 25 '25 16:11 nihalxkumar

@davewa It's still working

stillworking.webm

nihalxkumar avatar Nov 25 '25 18:11 nihalxkumar

Yeah, it's working for me too now... I must have done something dumb earlier... 🤷‍♂️

davewa avatar Nov 25 '25 22:11 davewa

@probably-neb It's ready

nihalxkumar avatar Nov 26 '25 06:11 nihalxkumar