From 4d65b2db7de21237f631a199d5765b8f0de9e718 Mon Sep 17 00:00:00 2001 From: cschen Date: Wed, 14 Aug 2024 11:08:10 +0200 Subject: [PATCH] fix: error in the worker that merged more operations than needed. --- src/buffer/worker.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/buffer/worker.rs b/src/buffer/worker.rs index 0d67e31..8f18190 100644 --- a/src/buffer/worker.rs +++ b/src/buffer/worker.rs @@ -141,12 +141,16 @@ impl ControllerWorker for BufferWorker { // this step_ver will be the version after we apply the operation // we give it to the controller so that he knows where it's at. let step_ver = oplog.version_union(&[lv.start], &last_ver); - - branch.merge(&oplog, oplog.local_version_ref()); + + // if you merge up until the oplog.local_version_ref() + // it's as if you are merging the whole iterator. + // Not just this change... let hash = if timer.step() { + branch.merge(&oplog, &step_ver); let hash = xxhash_rust::xxh3::xxh3_64(branch.content().to_string().as_bytes()); Some(i64::from_ne_bytes(hash.to_ne_bytes())) } else { None }; + let tc = crate::api::change::TextChange { start: dtop.start() as u32, end: dtop.end() as u32, @@ -174,7 +178,9 @@ impl ControllerWorker for BufferWorker { struct Timer(u32, u32); impl Timer { - fn new(period: u32) -> Self { Timer(0, period) } + fn new(period: u32) -> Self { + Timer(0, period) + } fn step(&mut self) -> bool { self.0 += 1; if self.0 >= self.1 {