diff --git a/src/operation_transformation/edited_text.rs b/src/operation_transformation/edited_text.rs index 3e7f7be..47cde49 100644 --- a/src/operation_transformation/edited_text.rs +++ b/src/operation_transformation/edited_text.rs @@ -3,10 +3,10 @@ use serde::{Deserialize, Serialize}; use super::{CursorPosition, Operation, TextWithCursors}; use crate::{ - diffs::{myers::diff, raw_operation::RawOperation}, operation_transformation::utils::{ cook_operations::cook_operations, elongate_operations::elongate_operations, }, + raw_operation::RawOperation, tokenizer::{Tokenizer, word_tokenizer::word_tokenizer}, utils::{history::History, side::Side, string_builder::StringBuilder}, }; @@ -65,7 +65,7 @@ where let original_tokens = (tokenizer)(original); let updated_tokens = (tokenizer)(&updated.text); - let diff: Vec> = diff(&original_tokens, &updated_tokens); + let diff: Vec> = RawOperation::vec_from(&original_tokens, &updated_tokens); Self::new( original, diff --git a/src/operation_transformation/utils/cook_operations.rs b/src/operation_transformation/utils/cook_operations.rs index 6ec3b43..8d09f6f 100644 --- a/src/operation_transformation/utils/cook_operations.rs +++ b/src/operation_transformation/utils/cook_operations.rs @@ -1,6 +1,4 @@ -use crate::{ - diffs::raw_operation::RawOperation, operation_transformation::Operation, utils::side::Side, -}; +use crate::{operation_transformation::Operation, raw_operation::RawOperation, utils::side::Side}; /// Turn raw operations into ordered operations while keeping track of the /// original token's indexes. diff --git a/src/operation_transformation/utils/elongate_operations.rs b/src/operation_transformation/utils/elongate_operations.rs index c0b25fb..57d1580 100644 --- a/src/operation_transformation/utils/elongate_operations.rs +++ b/src/operation_transformation/utils/elongate_operations.rs @@ -1,6 +1,6 @@ use core::iter; -use crate::diffs::raw_operation::RawOperation; +use crate::raw_operation::RawOperation; /// Elongates the operations by merging adjacent insertions and deletions that /// can be joined. This makes the subsequent merging of operations more @@ -24,7 +24,7 @@ where .flat_map(|next| match next { RawOperation::Insert(..) => match maybe_previous_insert.take() { Some(prev) if prev.is_right_joinable() && next.is_left_joinable() => { - maybe_previous_insert = Some(prev.extend(next)); + maybe_previous_insert = Some(prev.join(next)); Box::new(iter::empty()) as Box>> } prev => { @@ -34,7 +34,7 @@ where }, RawOperation::Delete(..) => match maybe_previous_delete.take() { Some(prev) if prev.is_right_joinable() && next.is_left_joinable() => { - maybe_previous_delete = Some(prev.extend(next)); + maybe_previous_delete = Some(prev.join(next)); Box::new(iter::empty()) as Box>> } prev => {