mirror of https://github.com/helix-editor/helix
Use the new imara-diff version
parent
760b83dbf4
commit
587ec24b04
|
@ -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)]
|
||||||
|
|
Loading…
Reference in New Issue