From 09a80150dfcee15574981c236e1904e1f63f8de8 Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Sun, 8 Aug 2021 23:15:01 -0700 Subject: [PATCH] Fix adding/removing whole files The 'remove unaligned lines at beginning of hunk' logic meant we just discarded the whole hunk. This breaks alignment again (previously fixed in 3ebbf268fd), but that should be fixed properly in the padding logic. --- CHANGELOG.md | 5 +++++ src/syntax.rs | 9 --------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c41290085..8c209927f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ## 0.7 (unreleased) +### Diffing + +Fixed issues when creating/removing a whole file meant that difftastic +didn't display anything. + ### Display Side-by-side display now uses "..." for column numbers when aligning diff --git a/src/syntax.rs b/src/syntax.rs index 3ac1cb795..d6203814c 100644 --- a/src/syntax.rs +++ b/src/syntax.rs @@ -832,17 +832,8 @@ pub fn aligned_lines( // different number of lines, we can end up with extra padding on // the side with fewer lines. // - // Work around that by discarding any lines at the beginning with - // aren't matched. - // // TODO: fix padding to be smarter. - // - // TODO: do the same for the end of the hunk. aligned_lines_(&lhs_lines, &rhs_lines, lhs_line_matches) - .iter() - .skip_while(|(lhs, rhs)| lhs.is_none() || rhs.is_none()) - .copied() - .collect() } /// Given two slices of contiguous line numbers, return pairs of