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