Skip to content

Commit

Permalink
fix: conflict check when reference right is none (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
darkskygit committed Jan 30, 2024
1 parent 1a344f7 commit e68ef6f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions libs/jwst-codec/src/doc/codec/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,11 @@ mod tests {
(include_bytes!("../../fixtures/database.bin").to_vec(), 1, 149),
(include_bytes!("../../fixtures/large.bin").to_vec(), 1, 9036),
(include_bytes!("../../fixtures/with-subdoc.bin").to_vec(), 2, 30),
(
include_bytes!("../../fixtures/edge-case-left-right-same-node.bin").to_vec(),
2,
243,
),
];

for (doc, clients, structs) in docs {
Expand Down
17 changes: 17 additions & 0 deletions libs/jwst-codec/src/doc/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,4 +608,21 @@ mod tests {
assert_eq!(&text.to_string(), "hello world");
});
}

#[test]
#[cfg_attr(any(miri, loom), ignore)]
fn test_apply_update() {
let updates = [
include_bytes!("../fixtures/basic.bin").to_vec(),
include_bytes!("../fixtures/database.bin").to_vec(),
include_bytes!("../fixtures/large.bin").to_vec(),
include_bytes!("../fixtures/with-subdoc.bin").to_vec(),
include_bytes!("../fixtures/edge-case-left-right-same-node.bin").to_vec(),
];

for update in updates {
let mut doc = Doc::new();
doc.apply_update_from_binary_v1(&update).unwrap();
}
}
}
2 changes: 1 addition & 1 deletion libs/jwst-codec/src/doc/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,6 @@ impl DocStore {
let mut right = right.get_mut_unchecked();
right.left = item_owner_ref.clone();
}
this.right = right.clone();
} else {
// no right, parent.start = this, delete this.left
if let Some(parent_sub) = &this.parent_sub {
Expand All @@ -565,6 +564,7 @@ impl DocStore {
}
}
}
this.right = right.clone();

let parent_deleted = parent.item.get().map(|item| item.deleted()).unwrap_or(false);

Expand Down
Binary file not shown.

0 comments on commit e68ef6f

Please sign in to comment.