mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-26 20:22:30 +00:00
Serialize deferred operations
This commit is contained in:
parent
d383ff30ce
commit
870fa5f278
4 changed files with 23 additions and 1 deletions
|
@ -327,6 +327,13 @@ impl Buffer {
|
|||
);
|
||||
}
|
||||
|
||||
let deferred_ops = message
|
||||
.deferred_operations
|
||||
.into_iter()
|
||||
.map(proto::deserialize_operation)
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
this.apply_ops(deferred_ops, cx)?;
|
||||
|
||||
Ok(this)
|
||||
}
|
||||
|
||||
|
@ -362,6 +369,16 @@ impl Buffer {
|
|||
proto::serialize_diagnostic_set(set.provider_name().to_string(), set.iter())
|
||||
})
|
||||
.collect(),
|
||||
deferred_operations: self
|
||||
.deferred_ops
|
||||
.iter()
|
||||
.map(proto::serialize_operation)
|
||||
.chain(
|
||||
self.text
|
||||
.deferred_ops()
|
||||
.map(|op| proto::serialize_operation(&Operation::Buffer(op.clone()))),
|
||||
)
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -270,6 +270,7 @@ message Buffer {
|
|||
repeated SelectionSet selections = 7;
|
||||
repeated DiagnosticSet diagnostic_sets = 8;
|
||||
uint32 lamport_timestamp = 9;
|
||||
repeated Operation deferred_operations = 10;
|
||||
}
|
||||
|
||||
message BufferFragment {
|
||||
|
|
|
@ -53,7 +53,7 @@ impl<T: Operation> OperationQueue<T> {
|
|||
}
|
||||
|
||||
pub fn iter(&self) -> impl Iterator<Item = &T> {
|
||||
self.0.cursor::<()>().map(|i| &i.0)
|
||||
self.0.iter().map(|i| &i.0)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1101,6 +1101,10 @@ impl Buffer {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn deferred_ops(&self) -> impl Iterator<Item = &Operation> {
|
||||
self.deferred_ops.iter()
|
||||
}
|
||||
|
||||
fn flush_deferred_ops(&mut self) -> Result<()> {
|
||||
self.deferred_replicas.clear();
|
||||
let mut deferred_ops = Vec::new();
|
||||
|
|
Loading…
Reference in a new issue