mirror of
https://github.com/loro-dev/loro.git
synced 2025-02-05 20:17:13 +00:00
fix: should commit before travel_change_ancestors (#599)
* fix: should commit before travel_change_ancestors * chore: changeest
This commit is contained in:
parent
df621a370c
commit
da249109bc
3 changed files with 18 additions and 0 deletions
5
.changeset/chatty-experts-clean.md
Normal file
5
.changeset/chatty-experts-clean.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"loro-crdt": patch
|
||||
---
|
||||
|
||||
fix: should commit before travel_change_ancestors #599
|
|
@ -1635,6 +1635,7 @@ impl LoroDoc {
|
|||
ids: &[ID],
|
||||
f: &mut dyn FnMut(ChangeMeta) -> ControlFlow<()>,
|
||||
) -> Result<(), ChangeTravelError> {
|
||||
self.commit_then_renew();
|
||||
struct PendingNode(ChangeMeta);
|
||||
impl PartialEq for PendingNode {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
|
|
|
@ -2467,3 +2467,15 @@ fn test_rust_get_value_by_path() {
|
|||
assert!(doc.get_by_str_path("tree/0/2").is_none()); // Invalid child index
|
||||
assert!(doc.get_by_str_path("tree/0/0/1").is_none()); // Invalid grandchild index
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn travel_before_commit() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let doc = LoroDoc::new();
|
||||
let map = doc.get_map("metadata");
|
||||
map.insert("key", "value")?;
|
||||
let last_frontiers = doc.state_frontiers();
|
||||
doc.travel_change_ancestors(&last_frontiers.to_vec(), &mut |_meta| {
|
||||
std::ops::ControlFlow::Continue(())
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue