mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-24 01:11:51 +00:00
Error if project is disconnected after getting completions response
This commit is contained in:
parent
fa3f100eff
commit
d0709e7bfa
1 changed files with 20 additions and 10 deletions
|
@ -3408,19 +3408,29 @@ impl Project {
|
||||||
position: Some(language::proto::serialize_anchor(&anchor)),
|
position: Some(language::proto::serialize_anchor(&anchor)),
|
||||||
version: serialize_version(&source_buffer.version()),
|
version: serialize_version(&source_buffer.version()),
|
||||||
};
|
};
|
||||||
cx.spawn_weak(|_, mut cx| async move {
|
cx.spawn_weak(|this, mut cx| async move {
|
||||||
let response = rpc.request(message).await?;
|
let response = rpc.request(message).await?;
|
||||||
|
|
||||||
source_buffer_handle
|
if this
|
||||||
.update(&mut cx, |buffer, _| {
|
.upgrade(&cx)
|
||||||
buffer.wait_for_version(deserialize_version(response.version))
|
.ok_or_else(|| anyhow!("project was dropped"))?
|
||||||
})
|
.read_with(&cx, |this, _| this.is_read_only())
|
||||||
.await;
|
{
|
||||||
|
return Err(anyhow!(
|
||||||
|
"failed to get completions: project was disconnected"
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
source_buffer_handle
|
||||||
|
.update(&mut cx, |buffer, _| {
|
||||||
|
buffer.wait_for_version(deserialize_version(response.version))
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
|
||||||
let completions = response.completions.into_iter().map(|completion| {
|
let completions = response.completions.into_iter().map(|completion| {
|
||||||
language::proto::deserialize_completion(completion, language.clone())
|
language::proto::deserialize_completion(completion, language.clone())
|
||||||
});
|
});
|
||||||
futures::future::try_join_all(completions).await
|
futures::future::try_join_all(completions).await
|
||||||
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Task::ready(Ok(Default::default()))
|
Task::ready(Ok(Default::default()))
|
||||||
|
|
Loading…
Reference in a new issue