Wait for incomplete buffers when handling incoming buffer file updates
This commit is contained in:
parent
7a629769b7
commit
77e322cb75
1 changed files with 21 additions and 12 deletions
|
@ -5074,20 +5074,29 @@ impl Project {
|
||||||
_: Arc<Client>,
|
_: Arc<Client>,
|
||||||
mut cx: AsyncAppContext,
|
mut cx: AsyncAppContext,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
let buffer_id = envelope.payload.buffer_id;
|
||||||
|
let is_incomplete = this.read_with(&cx, |this, _| {
|
||||||
|
this.incomplete_remote_buffers.contains_key(&buffer_id)
|
||||||
|
});
|
||||||
|
|
||||||
|
let buffer = if is_incomplete {
|
||||||
|
Some(
|
||||||
|
this.update(&mut cx, |this, cx| {
|
||||||
|
this.wait_for_remote_buffer(buffer_id, cx)
|
||||||
|
})
|
||||||
|
.await?,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
this.update(&mut cx, |this, cx| {
|
this.update(&mut cx, |this, cx| {
|
||||||
let payload = envelope.payload.clone();
|
let payload = envelope.payload.clone();
|
||||||
let buffer_id = payload.buffer_id;
|
if let Some(buffer) = buffer.or_else(|| {
|
||||||
if let Some(buffer) = this
|
this.opened_buffers
|
||||||
.opened_buffers
|
|
||||||
.get_mut(&buffer_id)
|
|
||||||
.and_then(|b| b.upgrade(cx))
|
|
||||||
.or_else(|| {
|
|
||||||
this.incomplete_remote_buffers
|
|
||||||
.get(&buffer_id)
|
.get(&buffer_id)
|
||||||
.cloned()
|
.and_then(|b| b.upgrade(cx))
|
||||||
.flatten()
|
}) {
|
||||||
})
|
|
||||||
{
|
|
||||||
let file = payload.file.ok_or_else(|| anyhow!("invalid file"))?;
|
let file = payload.file.ok_or_else(|| anyhow!("invalid file"))?;
|
||||||
let worktree = this
|
let worktree = this
|
||||||
.worktree_for_id(WorktreeId::from_proto(file.worktree_id), cx)
|
.worktree_for_id(WorktreeId::from_proto(file.worktree_id), cx)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue