Use the new imara-diff version

pull/10587/head
Armando Perez 2025-06-14 16:02:36 -05:00
parent 760b83dbf4
commit 587ec24b04
1 changed files with 10 additions and 9 deletions

View File

@ -170,16 +170,17 @@ pub fn compare_ropes(before: &Rope, after: &Rope) -> Transaction {
/// Compares `old` and `new` to generate a text diff
pub fn diff_ropes(before: RopeSlice, after: RopeSlice) -> String {
let file = InternedInput::new(RopeLines(before), RopeLines(after));
imara_diff::diff(
Algorithm::Histogram,
&file,
imara_diff::UnifiedDiffBuilder::new(&file),
let before = before.to_string();
let after = after.to_string();
let input = InternedInput::new(before.as_str(), after.as_str());
let mut diff = Diff::compute(Algorithm::Histogram, &input);
diff.postprocess_lines(&input);
diff.unified_diff(
&imara_diff::BasicLineDiffPrinter(&input.interner),
imara_diff::UnifiedDiffConfig::default(),
&input,
)
// Unsure why we get empty lines...
.split_inclusive('\n')
.filter(|line| !line.trim().is_empty())
.collect()
.to_string()
}
#[cfg(test)]