Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
ssh remoting: Handle OpenNewBuffer request (#19373)
Thorsten Balle6b9a8ef9bdb
diff --git a/crates/remote_server/src/headless_project.rs b/crates/remote_server/src/headless_project.rsindex e6eddac1d0e..4536cc94638 100644--- a/crates/remote_server/src/headless_project.rs+++ b/crates/remote_server/src/headless_project.rs@@ -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>,