my fork of dmp
Fix full overlap elimination for inserts with trailing deletes - prepare for minor release
Anubhab Bandyopadhyay 8 months ago
parent ca86210 · commit 0976fab
-rw-r--r--CHANGELOG.md5
-rw-r--r--Cargo.toml2
-rw-r--r--README.md2
-rw-r--r--src/dmp.rs5
-rw-r--r--tests/test.rs16
5 files changed, 17 insertions, 13 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 23d0fa0..8df6577 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,10 @@
# CHANGELOG.md
+## 0.5.1
+Fix:
+
+ - Fix full overlap elimination for inserts with trailing deletes by @aschamp-figma
+
## 0.5.0
Features:
diff --git a/Cargo.toml b/Cargo.toml
index 20fd8f4..66d8b26 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "diff-match-patch-rs"
-version = "0.5.0"
+version = "0.5.1"
edition = "2021"
authors = ["Anubhab Bandyopadhyay"]
homepage = "https://docs.rs/diff-match-patch-rs"
diff --git a/README.md b/README.md
index 924ddc2..58fc553 100644
--- a/README.md
+++ b/README.md
@@ -39,7 +39,7 @@ Benchmarks are maintained [diff-match-patch-bench repository](https://github.com
```toml
[dependencies]
-diff-match-patch-rs = "0.5.0"
+diff-match-patch-rs = "0.5.1"
```
### `Effitient` mode
diff --git a/src/dmp.rs b/src/dmp.rs
index 3bf1fb5..1258d8d 100644
--- a/src/dmp.rs
+++ b/src/dmp.rs
@@ -4494,17 +4494,16 @@ mod tests {
let mut diffs = vec![
Diff::delete(&"abcd1212".chars().collect::<Vec<_>>()[..]),
Diff::insert(&"1212".chars().collect::<Vec<_>>()[..]),
- Diff::equal(&"wxyz".chars().collect::<Vec<_>>()[..]),
+ Diff::equal(&"wxyz".chars().collect::<Vec<_>>()[..]),
];
let test = vec![
Diff::delete(&"abcd".chars().collect::<Vec<_>>()[..]),
Diff::equal(&"1212".chars().collect::<Vec<_>>()[..]),
Diff::insert(&"".chars().collect::<Vec<_>>()[..]),
- Diff::equal(&"wxyz".chars().collect::<Vec<_>>()[..]),
+ Diff::equal(&"wxyz".chars().collect::<Vec<_>>()[..]),
];
DiffMatchPatch::cleanup_semantic(&mut diffs);
assert_eq!(test, diffs);
-
}
#[test]
diff --git a/tests/test.rs b/tests/test.rs
index 35cd52d..4875c75 100644
--- a/tests/test.rs
+++ b/tests/test.rs
@@ -1362,7 +1362,7 @@ fn test_match_main() {
#[test]
fn test_patch_repeats_todo_import() -> Result<(), Error> {
let dmp = DiffMatchPatch::default();
-
+
// Create source and target strings
let source = r##"(
import { useState, useEffect } from "react";
@@ -1480,25 +1480,25 @@ export default function App() {
);
}
)"##;
-
+
// Create patches to transform source into target
let patches = dmp.patch_make(PatchInput::Texts::<Efficient>(source, target))?;
-
+
// Apply the patches to the source string
let (patched, results) = dmp.patch_apply(&patches, source)?;
-
+
// Verify all patches were applied successfully
assert!(results.iter().all(|&result| result));
-
+
// Verify the patched string equals the target
assert_eq!(target, patched);
-
+
// Also test with Compat mode
let patches_compat = dmp.patch_make(PatchInput::Texts::<Compat>(source, target))?;
let (patched_compat, results_compat) = dmp.patch_apply(&patches_compat, source)?;
-
+
assert!(results_compat.iter().all(|&result| result));
assert_eq!(target, patched_compat);
-
+
Ok(())
}