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
41.76k stars 2.18k forks source link

Support open file via URL #8482

Closed nhducit closed 4 months ago

nhducit commented 4 months ago

Check for existing issues

Describe the feature

Zed doesn't work with LocatorJS e.g. click on any component in the browser to open its code in your IDE.

LocatorJS will open a link to access the corresponding file in the editor.

vscode://file${projectPath}${filePath}:${line}:${column}
webstorm://open?file=${projectPath}${filePath}&line=${line}&column=${column}

Zed supporting this feature would enhance the developer experience for frontend developers.

I have limited experience with Rust. I think we need too update this function to support the feature.

https://github.com/zed-industries/zed/blob/main/crates/zed/src/open_listener.rs#L75

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

No response

Video: https://www.locatorjs.com/demo.mp4

mrnugget commented 4 months ago

I think what we need is to register a custom URL scheme, like here: https://github.com/chrisliuqq/mac-custom-url-scheme-to-script?tab=readme-ov-file#register-the-url-scheme-in-application

If you'd like to pair with me on this, feel free to book some time here: https://calendly.com/thorsten-ball-zed/60min I think we could make progress on this in an hour.

JosephTLyons commented 4 months ago

I believe that this is implemented via:

Closing the issue!

brandondrew commented 3 months ago

I'm really glad to see that you added a zed:// URL scheme but I'm confused as to the reason for adding file to the root. Is there anything else that will appear in a zed:// URL instead of a file path?

Unless I'm missing something important, I think the simplest and most logical structure would be like this:

zed:///Users/example/Desktop/a.txt

Not the 3 slashes, just like file:// URLs, where the first 2 are a part of the scheme (or perhaps are separators between the scheme and everything else), and the 3rd one represents the root of the drive, and thus is a part of the path. Line numbers can be added after a colon, and columns after another colon:

zed:///Users/example/Desktop/a.txt:7:42

If you think you might add other operations in the future, other than opening files, those can come directly after the first two slashes, so there's no need to worry about creating backwards incompatibility:

zed://update
zed://restart
zed://theme:Dracula
zed://branches:open_recent
ConradIrwin commented 3 months ago

It seemed clearer to me (zed://channel/X, zed://file/{X}, vs zed://channel/X being a channel and zed:///channel/X being a file) and is the same as VScode.