mirror of
https://github.com/zed-industries/zed.git
synced 2024-10-23 06:56:33 +00:00
ssh remoting: Handle OpenNewBuffer request (#19373)
Release Notes: - N/A
This commit is contained in:
parent
398d0396b6
commit
e6b9a8ef9b
1 changed files with 27 additions and 0 deletions
|
@ -154,6 +154,7 @@ impl HeadlessProject {
|
|||
client.add_request_handler(cx.weak_model(), Self::handle_remove_worktree);
|
||||
|
||||
client.add_model_request_handler(Self::handle_open_buffer_by_path);
|
||||
client.add_model_request_handler(Self::handle_open_new_buffer);
|
||||
client.add_model_request_handler(Self::handle_find_search_candidates);
|
||||
client.add_model_request_handler(Self::handle_open_server_settings);
|
||||
|
||||
|
@ -363,6 +364,32 @@ impl HeadlessProject {
|
|||
})
|
||||
}
|
||||
|
||||
pub async fn handle_open_new_buffer(
|
||||
this: Model<Self>,
|
||||
_message: TypedEnvelope<proto::OpenNewBuffer>,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<proto::OpenBufferResponse> {
|
||||
let (buffer_store, buffer) = this.update(&mut cx, |this, cx| {
|
||||
let buffer_store = this.buffer_store.clone();
|
||||
let buffer = this
|
||||
.buffer_store
|
||||
.update(cx, |buffer_store, cx| buffer_store.create_buffer(cx));
|
||||
anyhow::Ok((buffer_store, buffer))
|
||||
})??;
|
||||
|
||||
let buffer = buffer.await?;
|
||||
let buffer_id = buffer.read_with(&cx, |b, _| b.remote_id())?;
|
||||
buffer_store.update(&mut cx, |buffer_store, cx| {
|
||||
buffer_store
|
||||
.create_buffer_for_peer(&buffer, SSH_PEER_ID, cx)
|
||||
.detach_and_log_err(cx);
|
||||
})?;
|
||||
|
||||
Ok(proto::OpenBufferResponse {
|
||||
buffer_id: buffer_id.to_proto(),
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn handle_open_server_settings(
|
||||
this: Model<Self>,
|
||||
_: TypedEnvelope<proto::OpenServerSettings>,
|
||||
|
|
Loading…
Reference in a new issue