This commit is contained in:
Andras Schmelczer 2025-06-22 14:58:38 +01:00
commit df6ec254ca
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C

View file

@ -17,6 +17,9 @@ where
let mut maybe_previous_insert: Option<RawOperation<T>> = None;
let mut maybe_previous_delete: Option<RawOperation<T>> = None;
// We don't elongate `equals` as they're needed to maintain cursor positions
// when merging against deletes.
let mut result: Vec<RawOperation<T>> = raw_operations
.into_iter()
.flat_map(|next| match next {
@ -60,68 +63,3 @@ where
result
}
// #[cfg(test)]
// mod tests {
// use super::*;
// #[test]
// fn test_elongate_operations_empty() {
// let operations: Vec<RawOperation<()>> = vec![];
// let result = elongate_operations(operations);
// assert_eq!(result, vec![]);
// }
// #[test]
// fn test_elongate_operations_single_operation() {
// let operations = vec![RawOperation::Insert(vec!["test".into()])];
// let result = elongate_operations(operations);
// assert_eq!(result.len(), 1);
// assert!(matches!(result[0], RawOperation::Insert(_)));
// }
// #[test]
// fn test_elongate_operations_interleaved() {
// let operations = vec![
// RawOperation::Insert(vec!["a".into()]),
// RawOperation::Delete(vec!["b".into()]),
// RawOperation::Insert(vec!["c".into()]),
// RawOperation::Delete(vec!["d".into()]),
// ];
// let result = elongate_operations(operations);
// assert_eq!(result.len(), 2);
// assert!(matches!(result[0], RawOperation::Insert(_)));
// assert!(matches!(result[1], RawOperation::Delete(_)));
// }
// #[test]
// fn test_elongate_operations_with_equal() {
// let operations = vec![
// RawOperation::Equal(vec!["a".into()]),
// RawOperation::Equal(vec!["b".into()]),
// RawOperation::Insert(vec!["c".into()]),
// RawOperation::Insert(vec!["d".into()]),
// ];
// let result = elongate_operations(operations);
// assert_eq!(result.len(), 2);
// assert!(matches!(result[0], RawOperation::Equal(_)));
// assert!(matches!(result[1], RawOperation::Insert(_)));
// }
// #[test]
// fn test_elongate_operations_mixed_sequence() {
// let operations = vec![
// RawOperation::Insert(vec!["a".into()]),
// RawOperation::Equal(vec!["b".into()]),
// RawOperation::Delete(vec!["c".into()]),
// RawOperation::Equal(vec!["d".into()]),
// ];
// let result = elongate_operations(operations);
// assert_eq!(result.len(), 4);
// assert!(matches!(result[0], RawOperation::Insert(_)));
// assert!(matches!(result[1], RawOperation::Equal(_)));
// assert!(matches!(result[2], RawOperation::Delete(_)));
// assert!(matches!(result[3], RawOperation::Equal(_)));
// }
// }