From 17e6a54294e37b9be42e58e8cf62bb3b188eb4c0 Mon Sep 17 00:00:00 2001 From: Wilfred Hughes Date: Fri, 7 Feb 2025 09:03:10 -0800 Subject: [PATCH] Ensure side-by-side-show-both always uses two columns Fixes #812 --- CHANGELOG.md | 5 +++++ src/display/side_by_side.rs | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 544e92e24..d5736b37b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ When diffing directories, difftastic now ignores the `.git` directory. +### Display + +Fixed an issue where `--display=side-by-side-show-both` would not use +a two-column display when one file was empty. + ### Command Line Interface Difftastic no longer accepts the `--missing-as-empty`. This has had no diff --git a/src/display/side_by_side.rs b/src/display/side_by_side.rs index 5961af2d1..954b5ab0c 100644 --- a/src/display/side_by_side.rs +++ b/src/display/side_by_side.rs @@ -388,7 +388,12 @@ pub(crate) fn print( .map(|l| replace_tabs(l, display_options.tab_width)) .collect(); - if lhs_src.is_empty() { + if lhs_src.is_empty() + && !matches!( + display_options.display_mode, + DisplayMode::SideBySideShowBoth + ) + { for line in display_single_column( display_path, old_path, @@ -402,7 +407,12 @@ pub(crate) fn print( println!(); return; } - if rhs_src.is_empty() { + if rhs_src.is_empty() + && !matches!( + display_options.display_mode, + DisplayMode::SideBySideShowBoth + ) + { for line in display_single_column( display_path, old_path,