fix: tree diff calc children should be sorted by idlp (#401)

This commit is contained in:
Leon Zhao 2024-07-13 23:26:38 +08:00 committed by GitHub
parent 71e5afa6cc
commit 00e9c8d031
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 214 additions and 935 deletions

View file

@ -161,6 +161,12 @@ impl Actor {
}
pub fn check_history(&mut self) {
// let json = self
// .loro
// .export_json_updates(&Default::default(), &self.loro.oplog_vv());
// let string = serde_json::to_string_pretty(&json).unwrap();
// tracing::info!("json = {}", string);
for (f, v) in self.history.iter() {
let f = Frontiers::from(f);
let from = &self.loro.state_frontiers();

File diff suppressed because it is too large Load diff

View file

@ -449,7 +449,12 @@ impl TreeCacheForDiff {
ans.push((*tree_id, op.position.clone(), op.id_full()));
}
}
ans.sort_by(|a, b| a.1.cmp(&b.1));
// The children should be sorted by the position.
// If the fractional index is the same, then sort by the lamport and peer.
ans.sort_by(|a, b| {
a.1.cmp(&b.1)
.then(a.2.lamport.cmp(&b.2.lamport).then(a.2.peer.cmp(&b.2.peer)))
});
ans
}
}