mirror of
https://github.com/loro-dev/loro.git
synced 2025-01-22 21:07:43 +00:00
fix: should not reset the state when calling checkout to latest (#265)
This commit is contained in:
parent
3a4ed97e0b
commit
9c25e6d273
2 changed files with 19 additions and 0 deletions
|
@ -260,6 +260,8 @@ impl LoroDoc {
|
|||
immediate_renew: bool,
|
||||
) {
|
||||
if !self.auto_commit.load(Acquire) {
|
||||
// if not auto_commit, nothing should happen
|
||||
// because the global txn is not used
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -660,6 +662,11 @@ impl LoroDoc {
|
|||
}
|
||||
|
||||
pub fn checkout_to_latest(&self) {
|
||||
if !self.is_detached() {
|
||||
self.commit_then_renew();
|
||||
return;
|
||||
}
|
||||
|
||||
debug_log::debug_log!("Attached {}", self.peer_id());
|
||||
let f = self.oplog_frontiers();
|
||||
self.checkout(&f).unwrap();
|
||||
|
|
|
@ -8,6 +8,18 @@ use loro_internal::{
|
|||
};
|
||||
use serde_json::json;
|
||||
|
||||
#[test]
|
||||
fn issue_502() -> LoroResult<()> {
|
||||
let doc = LoroDoc::new_auto_commit();
|
||||
doc.get_map("map").insert("stringA", "Original data")?;
|
||||
doc.commit_then_renew();
|
||||
doc.get_map("map").insert("stringA", "Updated data")?;
|
||||
doc.attach();
|
||||
doc.get_map("map").insert("stringB", "Something else")?;
|
||||
doc.commit_then_renew();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_225() -> LoroResult<()> {
|
||||
let doc = LoroDoc::new_auto_commit();
|
||||
|
|
Loading…
Reference in a new issue