Skip to content

Commit

Permalink
Fix automerge merge logic
Browse files Browse the repository at this point in the history
  • Loading branch information
adzialocha committed Dec 8, 2024
1 parent 6fbf80d commit 97ae6aa
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ mod imp {
println!("app: {}", text);
let mut doc = self.automerge.borrow_mut();
let current_text = doc.text(&self.root).unwrap();
if text == current_text { return; }
if text == current_text {
return;
}

doc.update_text(&self.root, text).unwrap();

Expand Down Expand Up @@ -129,13 +131,13 @@ mod imp {
let w = window.clone();
let app = application.clone();
glib::spawn_future_local(async move {
while let Some(msg) = rx.recv().await {
while let Some(bytes) = rx.recv().await {
//println!("got {:?}", msg);
let text = {
let mut doc_remote = AutoCommit::load(&msg).unwrap();
let mut new_doc = AutoCommit::new();
new_doc.merge(&mut doc_remote).unwrap();
new_doc.text(&app.imp().root).unwrap()
let mut doc_remote = AutoCommit::load(&bytes).unwrap();
let mut doc_local = app.imp().automerge.borrow_mut();
doc_local.merge(&mut doc_remote).unwrap();
doc_local.text(&app.imp().root).unwrap()
};
dbg!(&text);
w.set_text(&text);
Expand Down

0 comments on commit 97ae6aa

Please sign in to comment.