Open URIs from the CLI, support for the zed:// URI scheme on Linux (#14104)

Allows Zed to open custom `zed://` links (redirects from
https://zed.dev/channels) on Linux used XDG MIME types.

This PR also allows the CLI to be able to open Zed (`zed://`) URIs
directly instead of executing the main executable in
`/usr/libexec/zed-editor`.


Release Notes:

- Linux: Allow `zed.dev/channel` (`zed://`) URIs to open on Linux
- CLI: Ability to open URIs from the command line

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
Cappy Ishihara 2024-07-17 03:49:15 +07:00 committed by GitHub
parent 64a796d436
commit 0c6105992c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 64 additions and 31 deletions

View file

@ -22,7 +22,7 @@ use welcome::{show_welcome_view, FIRST_OPEN};
use workspace::item::ItemHandle;
use workspace::{AppState, Workspace};
use crate::{init_headless, init_ui};
use crate::{handle_open_request, init_headless, init_ui};
#[derive(Default, Debug)]
pub struct OpenRequest {
@ -223,6 +223,7 @@ pub async fn handle_cli_connection(
if let Some(request) = requests.next().await {
match request {
CliRequest::Open {
urls,
paths,
wait,
open_new_workspace,
@ -257,6 +258,27 @@ pub async fn handle_cli_connection(
return;
}
if !urls.is_empty() {
cx.update(|cx| {
match OpenRequest::parse(urls, cx) {
Ok(open_request) => {
handle_open_request(open_request, app_state.clone(), cx);
responses.send(CliResponse::Exit { status: 0 }).log_err();
}
Err(e) => {
responses
.send(CliResponse::Stderr {
message: format!("{e}"),
})
.log_err();
responses.send(CliResponse::Exit { status: 1 }).log_err();
}
};
})
.log_err();
return;
}
if let Err(e) = cx
.update(|cx| init_ui(app_state.clone(), cx))
.and_then(|r| r)