Fix potential movable list bug (#354)

* fix: upgrade wasm-bindgen to fix str free err

* chore: fix ci

* fix: potential bug in movable list op group
This commit is contained in:
Zixuan Chen 2024-05-09 15:46:19 +08:00 committed by GitHub
parent 0660b1a1be
commit a9484b48a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -295,8 +295,13 @@ impl OpGroupTrait for MovableListOpGroup {
let full_id = op.id_full();
let mapping = self
.elem_mappings
.get_mut(elem_id)
.unwrap()
.entry(*elem_id)
.or_insert_with(|| {
MovableListTarget::Multiple(Box::new(MultipleInner {
poses: BTreeSet::default(),
values: BTreeSet::default(),
}))
})
.upgrade(*elem_id);
mapping.values.insert(GroupedMapOpInfo {
value: value.clone(),
@ -309,6 +314,21 @@ impl OpGroupTrait for MovableListOpGroup {
for (i, v) in self.arena.iter_value_slice(slice.to_range()).enumerate() {
let id = start_id.inc(i as i32);
let full_id = op.id_full().inc(i as i32);
if let Some(target) = self.elem_mappings.get_mut(&id) {
let inner = target.upgrade(id);
inner.poses.insert(GroupedMapOpInfo {
value: (),
counter: full_id.counter,
lamport: full_id.lamport,
peer: full_id.peer,
});
inner.values.insert(GroupedMapOpInfo {
value: v.clone(),
counter: full_id.counter,
lamport: full_id.lamport,
peer: full_id.peer,
});
} else {
self.elem_mappings.insert(
id,
MovableListTarget::One {
@ -318,12 +338,18 @@ impl OpGroupTrait for MovableListOpGroup {
);
}
}
}
crate::container::list::list_op::InnerListOp::Move { from_id, .. } => {
let full_id = op.id_full();
let mapping = self
.elem_mappings
.get_mut(from_id)
.unwrap()
.entry(*from_id)
.or_insert_with(|| {
MovableListTarget::Multiple(Box::new(MultipleInner {
poses: BTreeSet::default(),
values: BTreeSet::default(),
}))
})
.upgrade(*from_id);
mapping.poses.insert(GroupedMapOpInfo {
value: (),