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:
parent
64a796d436
commit
0c6105992c
4 changed files with 64 additions and 31 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue