mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 15:44:31 +03:00
Error if project is disconnected after getting code actions response
This commit is contained in:
parent
5581674f8f
commit
2a0ddd99d2
@ -3579,7 +3579,7 @@ impl Project {
|
||||
} else if let Some(project_id) = self.remote_id() {
|
||||
let rpc = self.client.clone();
|
||||
let version = buffer.version();
|
||||
cx.spawn_weak(|_, mut cx| async move {
|
||||
cx.spawn_weak(|this, mut cx| async move {
|
||||
let response = rpc
|
||||
.request(proto::GetCodeActions {
|
||||
project_id,
|
||||
@ -3590,17 +3590,27 @@ impl Project {
|
||||
})
|
||||
.await?;
|
||||
|
||||
buffer_handle
|
||||
.update(&mut cx, |buffer, _| {
|
||||
buffer.wait_for_version(deserialize_version(response.version))
|
||||
})
|
||||
.await;
|
||||
if this
|
||||
.upgrade(&cx)
|
||||
.ok_or_else(|| anyhow!("project was dropped"))?
|
||||
.read_with(&cx, |this, _| this.is_read_only())
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"failed to get code actions: project was disconnected"
|
||||
));
|
||||
} else {
|
||||
buffer_handle
|
||||
.update(&mut cx, |buffer, _| {
|
||||
buffer.wait_for_version(deserialize_version(response.version))
|
||||
})
|
||||
.await;
|
||||
|
||||
response
|
||||
.actions
|
||||
.into_iter()
|
||||
.map(language::proto::deserialize_code_action)
|
||||
.collect()
|
||||
response
|
||||
.actions
|
||||
.into_iter()
|
||||
.map(language::proto::deserialize_code_action)
|
||||
.collect()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
Task::ready(Ok(Default::default()))
|
||||
|
Loading…
Reference in New Issue
Block a user