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 authored Jan 27, 2024
1 parent 4d6a29c commit 01ec08a
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[env]
CARGO_WORKSPACE_DIR = { value = "", relative = true }

[unstable]
gc = true
5 changes: 5 additions & 0 deletions y-octo/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 y-octo/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 y-octo/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 01ec08a

Please sign in to comment.