Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Ensure project is still alive by the time remote LSP request starts

Antonio Scandurra5e37c893c2a3
diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs
index 2daa959cc87..90985f88104 100644
--- a/crates/project/src/project.rs
+++ b/crates/project/src/project.rs
@@ -4210,7 +4210,13 @@ impl Project {
let rpc = self.client.clone();
let message = request.to_proto(project_id, buffer);
return cx.spawn_weak(|this, cx| async move {
+ // Ensure the project is still alive by the time the task
+ // is scheduled.
+ this.upgrade(&cx)
+ .ok_or_else(|| anyhow!("project dropped"))?;
+
let response = rpc.request(message).await?;
+
let this = this
.upgrade(&cx)
.ok_or_else(|| anyhow!("project dropped"))?;