pub fn diff_with_slider_heuristics<T: AsRef<[u8]>>(
algorithm: Algorithm,
input: &InternedInput<T>,
) -> DiffAvailable on crate feature
blob only.Expand description
Compute a diff with Git’s slider heuristics to produce more intuitive diffs.
This function uses Diff from imara-diff
that supports postprocessing with slider heuristics. The slider heuristics move
diff hunks to more intuitive locations based on indentation and other factors,
resulting in diffs that are more readable and match Git’s output more closely.
§Examples
use gix_diff::blob::{diff_with_slider_heuristics, Algorithm, InternedInput};
let before = "fn foo() {\n let x = 1;\n}\n";
let after = "fn foo() {\n let x = 2;\n}\n";
let input = InternedInput::new(before, after);
let diff = diff_with_slider_heuristics(Algorithm::Histogram, &input);
// The diff now has slider heuristics applied
assert_eq!(diff.count_removals(), 1);
assert_eq!(diff.count_additions(), 1);