Deserialize buffers synchronously when deserializing project transaction
On guests, this ensures we never miss updates to subsequent buffers in the project transaction that arrive while we're waiting for edits on a prior buffer in the transaction.
This commit is contained in:
parent
8d3b7e996f
commit
2dbea2804c
1 changed files with 16 additions and 9 deletions
|
@ -2594,18 +2594,26 @@ impl Project {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deserialize_project_transaction(
|
fn deserialize_project_transaction(
|
||||||
&self,
|
&mut self,
|
||||||
message: proto::ProjectTransaction,
|
message: proto::ProjectTransaction,
|
||||||
push_to_history: bool,
|
push_to_history: bool,
|
||||||
cx: &mut ModelContext<Self>,
|
cx: &mut ModelContext<Self>,
|
||||||
) -> Task<Result<ProjectTransaction>> {
|
) -> Task<Result<ProjectTransaction>> {
|
||||||
cx.spawn(|this, mut cx| async move {
|
|
||||||
let mut project_transaction = ProjectTransaction::default();
|
let mut project_transaction = ProjectTransaction::default();
|
||||||
for (buffer, transaction) in message.buffers.into_iter().zip(message.transactions) {
|
for (buffer, transaction) in message.buffers.into_iter().zip(message.transactions) {
|
||||||
let buffer =
|
let buffer = match self.deserialize_buffer(buffer, cx) {
|
||||||
this.update(&mut cx, |this, cx| this.deserialize_buffer(buffer, cx))?;
|
Ok(buffer) => buffer,
|
||||||
let transaction = language::proto::deserialize_transaction(transaction)?;
|
Err(error) => return Task::ready(Err(error)),
|
||||||
|
};
|
||||||
|
let transaction = match language::proto::deserialize_transaction(transaction) {
|
||||||
|
Ok(transaction) => transaction,
|
||||||
|
Err(error) => return Task::ready(Err(error)),
|
||||||
|
};
|
||||||
|
project_transaction.0.insert(buffer, transaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
cx.spawn_weak(|_, mut cx| async move {
|
||||||
|
for (buffer, transaction) in &project_transaction.0 {
|
||||||
buffer
|
buffer
|
||||||
.update(&mut cx, |buffer, _| {
|
.update(&mut cx, |buffer, _| {
|
||||||
buffer.wait_for_edits(transaction.edit_ids.iter().copied())
|
buffer.wait_for_edits(transaction.edit_ids.iter().copied())
|
||||||
|
@ -2617,9 +2625,8 @@ impl Project {
|
||||||
buffer.push_transaction(transaction.clone(), Instant::now());
|
buffer.push_transaction(transaction.clone(), Instant::now());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
project_transaction.0.insert(buffer, transaction);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(project_transaction)
|
Ok(project_transaction)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue