Add mergeTextWithHistory function
This commit is contained in:
parent
c0333c1146
commit
779579d38f
18 changed files with 285 additions and 100 deletions
|
|
@ -1,8 +1,10 @@
|
|||
use crate::{diffs::raw_operation::RawOperation, operation_transformation::Operation};
|
||||
use crate::{
|
||||
diffs::raw_operation::RawOperation, operation_transformation::Operation, utils::side::Side,
|
||||
};
|
||||
|
||||
/// Turn raw operations into ordered operations while keeping track of the
|
||||
/// original token's indexes.
|
||||
pub fn cook_operations<I, T>(raw_operations: I) -> impl Iterator<Item = Operation<T>>
|
||||
pub fn cook_operations<I, T>(raw_operations: I, side: Side) -> impl Iterator<Item = Operation<T>>
|
||||
where
|
||||
I: IntoIterator<Item = RawOperation<T>>,
|
||||
T: PartialEq + Clone + std::fmt::Debug,
|
||||
|
|
@ -27,15 +29,18 @@ where
|
|||
|
||||
op
|
||||
}
|
||||
RawOperation::Insert(tokens) => Operation::create_insert(original_text_index, tokens),
|
||||
RawOperation::Insert(tokens) => {
|
||||
Operation::create_insert(original_text_index, tokens, side)
|
||||
}
|
||||
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)
|
||||
Operation::create_delete(original_text_index, length, side)
|
||||
};
|
||||
|
||||
original_text_index += length;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue