From 587ec24b04d61959a6a7c9270256c497d2eb0974 Mon Sep 17 00:00:00 2001 From: Armando Perez Date: Sat, 14 Jun 2025 16:02:36 -0500 Subject: [PATCH] Use the new imara-diff version --- helix-core/src/diff.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/helix-core/src/diff.rs b/helix-core/src/diff.rs index 0defe5fc9..f45200e29 100644 --- a/helix-core/src/diff.rs +++ b/helix-core/src/diff.rs @@ -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)]