Move Side to EditedText from Operation

This commit is contained in:
Andras Schmelczer 2025-10-26 20:23:22 +00:00
parent 8a52034426
commit de89532880
6 changed files with 119 additions and 55 deletions

View file

@ -1,10 +1,10 @@
use std::fmt::Debug;
use crate::{operation_transformation::Operation, raw_operation::RawOperation, types::side::Side};
use crate::{operation_transformation::Operation, raw_operation::RawOperation};
/// Turn raw operations into ordered operations while keeping track of the
/// original token's indexes.
pub fn cook_operations<I, T>(raw_operations: I, side: Side) -> impl Iterator<Item = Operation<T>>
pub fn cook_operations<I, T>(raw_operations: I) -> impl Iterator<Item = Operation<T>>
where
I: IntoIterator<Item = RawOperation<T>>,
T: PartialEq + Clone + Debug,
@ -29,18 +29,15 @@ where
op
}
RawOperation::Insert(tokens) => {
Operation::create_insert(original_text_index, tokens, side)
}
RawOperation::Insert(tokens) => Operation::create_insert(original_text_index, tokens),
RawOperation::Delete(..) => {
let op = if cfg!(debug_assertions) {
Operation::create_delete_with_text(
original_text_index,
raw_operation.get_original_text(),
side,
)
} else {
Operation::create_delete(original_text_index, length, side)
Operation::create_delete(original_text_index, length)
};
original_text_index += length;