Skip to content

Commit

Permalink
fix: remove additional prefix on path printing
Browse files Browse the repository at this point in the history
Signed-off-by: Ismael González <[email protected]>
  • Loading branch information
ismaelgv committed Nov 28, 2021
1 parent 68c2922 commit 72e94e3
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,12 @@ impl Printer {
return;
}

let source_parent = source.parent().unwrap().to_string_lossy().to_string();
let source_name = source.file_name().unwrap().to_string_lossy().to_string();
let target_parent = target.parent().unwrap().to_string_lossy().to_string();
let mut source_parent = source.parent().unwrap().to_string_lossy().to_string();
let mut source_name = source.file_name().unwrap().to_string_lossy().to_string();
let mut target_parent = target.parent().unwrap().to_string_lossy().to_string();
let mut target_name = target.file_name().unwrap().to_string_lossy().to_string();


// Avoid diffing if not coloring output
if self.mode == PrinterMode::Color {
target_name = self.string_diff(
Expand All @@ -131,11 +132,20 @@ impl Printer {
)
}

source_name = self.colors.source.paint(&source_name).to_string();

if source_parent != "" {
source_parent = self.colors.source.paint(format!("{}/", source_parent)).to_string();
}
if target_parent != "" {
target_parent = self.colors.target.paint(format!("{}/", target_parent)).to_string();
}

self.print(&format!(
"{}{} -> {}{}",
self.colors.source.paint(format!("{}/", source_parent)),
self.colors.source.paint(&source_name),
self.colors.target.paint(format!("{}/", target_parent)),
source_parent,
source_name,
target_parent,
target_name
));
}
Expand Down

0 comments on commit 72e94e3

Please sign in to comment.