zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
46.88k stars 2.69k forks source link

Support `cmd + click` open hyperlinks in the terminal #7630

Open emersonjds opened 7 months ago

emersonjds commented 7 months ago

Check for existing issues

Describe the feature

During development, it is normal to have a link to run the project where we click to see the execution in the browser, either in readme.MD or in the terminal itself when it generates a link to follow the development.

What happens is that there is no such feature, I believe that implementing it would greatly help the developer's experience

If applicable, add mockups / screenshots to help present your vision of the feature

How it works today

https://github.com/zed-industries/zed/assets/12503997/ec7eb97a-cce3-427e-af17-aa1da103bff4

How it should work

https://github.com/zed-industries/zed/assets/12503997/cf3fb2e8-37f9-4584-b522-3ab0ecb31f54

jasongitmail commented 7 months ago

+ within code comments too

JosephTLyons commented 7 months ago

Hey @emersonjds, just wanted to mention that the ability to cmd-click urls in editors landed in this week's preview and will be shipping to stable next Wednesday.

We have this issue here for tracking clickable links in popovers:

I think that only leaves us with needing an issue for clickable hyperlinks in the terminal. Let's use this issue for that.

emersonjds commented 7 months ago

@JosephTLyons This is great, I'm following each evolution of the project and I admire many platforms that work for the developer experience, thank you for your work and team #goZED

N8th8n8el commented 7 months ago

Opening links with Cmd+Click is already implemented: https://github.com/zed-industries/zed/assets/19362696/baf81be8-455a-4b54-94ab-94627807cbd2

Is there perhaps a bug? Seem like in the How it works today example the feature just doesn't work.

tylerchr commented 7 months ago

Very welcome improvement!

One quirk I noticed almost immediately is that the URL pattern-matcher doesn't seem to recognize URLs with query string parameters.

$ # this is cmd-clickable
$ echo https://google.com
https://google.com

$ # this is NOT cmd-clickable
$ echo https://google.com\?q\=zed+editor
https://google.com?q=zed+editor
SomeoneToIgnore commented 7 months ago

Here's the regex (copied from Alacritty code originally): https://github.com/zed-industries/zed/blob/7956a9a547949cf826d3e30f46c12a7edef67316/crates/terminal/src/terminal.rs#L382

and this is how we use it to match things: https://github.com/zed-industries/zed/blob/7956a9a547949cf826d3e30f46c12a7edef67316/crates/terminal/src/terminal.rs#L794

It would be great to write tests for those matches, but not sure it's as easy as just fixing the regex.

emersonjds commented 6 months ago

Opening links with Cmd+Click is already implemented: https://github.com/zed-industries/zed/assets/19362696/baf81be8-455a-4b54-94ab-94627807cbd2

Is there perhaps a bug? Seem like in the How it works today example the feature just doesn't work.

The idea is that if you click on any link within a file or in a README.md, the editor understands that it should open this link in a browser, not just links provided by the integrated terminal

stabildev commented 4 months ago

Cmd + Clicking links in the terminal (with query params) does not work for me

romans-ovo commented 3 months ago

Possibly related, when editor panel is active, Cmd+Clicking in terminal is not working, instead a click will focus the terminal panel. Releasing and pressing Cmd again will work as intended. Perhaps this is the cause for remaining problems:

Screenshot 2024-05-25 at 11 00 43
stephanlachnit commented 4 weeks ago

Can confirm that this doesn't work if there are query parameters, which happens e.g. for all GitLab Merge Request links. MWE:

# this works
echo https://google.com
# this doesn't
echo https://google.com/search?country=de