mirror of
https://github.com/loro-dev/loro.git
synced 2025-01-23 13:39:12 +00:00
fix: op counter
This commit is contained in:
parent
9fefd75fb6
commit
d1d242578f
4 changed files with 6 additions and 7 deletions
|
@ -68,20 +68,21 @@ impl ListContainer {
|
|||
let id = store.next_id();
|
||||
let mut offset = 0;
|
||||
for item in op.items() {
|
||||
// TODO avoid clone
|
||||
let item = item.clone().into_event_format();
|
||||
match item {
|
||||
DeltaItem::Retain { len, .. } => index += len,
|
||||
DeltaItem::Insert { value, .. } => {
|
||||
let len = value.len();
|
||||
let id = id.inc(offset);
|
||||
offset += 1;
|
||||
offset += len as i32;
|
||||
let op = self.apply_batch_insert(index, value, id);
|
||||
index += len;
|
||||
ops.push(op);
|
||||
}
|
||||
DeltaItem::Delete(len) => {
|
||||
let id = id.inc(offset);
|
||||
offset += 1;
|
||||
offset += len as i32;
|
||||
let op = self.apply_delete(index, len, id);
|
||||
ops.push(op);
|
||||
}
|
||||
|
|
|
@ -65,14 +65,14 @@ impl TextContainer {
|
|||
DeltaItem::Insert { value, .. } => {
|
||||
let len = value.len();
|
||||
let id = id.inc(offset);
|
||||
offset += 1;
|
||||
offset += len as i32;
|
||||
let op = self.apply_insert(index, value, id);
|
||||
index += len;
|
||||
ops.push(op);
|
||||
}
|
||||
DeltaItem::Delete(len) => {
|
||||
let id = id.inc(offset);
|
||||
offset += 1;
|
||||
offset += *len as i32;
|
||||
let op = self.apply_delete(index, *len, id);
|
||||
ops.push(op);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ use tabled::{TableIteratorExt, Tabled};
|
|||
|
||||
use crate::{
|
||||
array_mut_ref,
|
||||
container::{registry::ContainerWrapper, temp::ContainerTemp, ContainerID},
|
||||
container::{registry::ContainerWrapper, ContainerID},
|
||||
delta::DeltaItem,
|
||||
event::{Diff, Observer},
|
||||
id::ClientID,
|
||||
|
|
|
@ -117,7 +117,6 @@ impl Transaction {
|
|||
|
||||
fn apply_ops_emit_event(&mut self) {
|
||||
let compressed_op = std::mem::take(&mut self.compressed_op);
|
||||
println!("compressed op {:?}", compressed_op);
|
||||
let events = self.with_store_hierarchy_mut(|_txn, store, hierarchy| {
|
||||
let mut events = Vec::with_capacity(compressed_op.len());
|
||||
for op in compressed_op {
|
||||
|
@ -128,7 +127,6 @@ impl Transaction {
|
|||
let container_id = container.id().clone();
|
||||
let type_ = container_id.container_type();
|
||||
let store_ops = container.apply_txn_op(store, &op);
|
||||
println!("store ops: {:?}", store_ops);
|
||||
drop(container);
|
||||
let (old_version, new_version) = store.append_local_ops(&store_ops);
|
||||
let new_version = new_version.into();
|
||||
|
|
Loading…
Reference in a new issue