Skip to content

Commit

Permalink
Merge pull request #234 from epage/color
Browse files Browse the repository at this point in the history
fix(snap): Swap diff colors
  • Loading branch information
epage authored Oct 2, 2023
2 parents 3979432 + 9dddde7 commit b955de0
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions crates/snapbox/src/report/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ pub fn write_diff(

if !rendered {
if let Some(expected_name) = expected_name {
writeln!(writer, "{} {}:", expected_name, palette.info("(expected)"))?;
writeln!(writer, "{} {}:", expected_name, palette.error("(expected)"))?;
} else {
writeln!(writer, "{}:", palette.info("Expected"))?;
writeln!(writer, "{}:", palette.error("Expected"))?;
}
writeln!(writer, "{}", palette.info(&expected))?;
writeln!(writer, "{}", palette.error(&expected))?;
if let Some(actual_name) = actual_name {
writeln!(writer, "{} {}:", actual_name, palette.error("(actual)"))?;
writeln!(writer, "{} {}:", actual_name, palette.info("(actual)"))?;
} else {
writeln!(writer, "{}:", palette.error("Actual"))?;
writeln!(writer, "{}:", palette.info("Actual"))?;
}
writeln!(writer, "{}", palette.error(&actual))?;
writeln!(writer, "{}", palette.info(&actual))?;
}
Ok(())
}
Expand Down Expand Up @@ -64,19 +64,19 @@ fn write_diff_inner(
writeln!(
writer,
"{}",
palette.info(format_args!("{:->4} expected: {}", "", expected_name))
palette.error(format_args!("{:->4} expected: {}", "", expected_name))
)?;
} else {
writeln!(writer, "{}", palette.info(format_args!("--- Expected")))?;
writeln!(writer, "{}", palette.error(format_args!("--- Expected")))?;
}
if let Some(actual_name) = actual_name {
writeln!(
writer,
"{}",
palette.error(format_args!("{:+>4} actual: {}", "", actual_name))
palette.info(format_args!("{:+>4} actual: {}", "", actual_name))
)?;
} else {
writeln!(writer, "{}", palette.error(format_args!("+++ Actual")))?;
writeln!(writer, "{}", palette.info(format_args!("+++ Actual")))?;
}
let changes = changes
.ops()
Expand Down Expand Up @@ -137,10 +137,17 @@ fn write_diff_inner(
elided = false;
match change.tag() {
similar::ChangeTag::Insert => {
write_change(writer, change, "+", palette.actual, palette.error, palette)?;
write_change(writer, change, "+", palette.actual, palette.info, palette)?;
}
similar::ChangeTag::Delete => {
write_change(writer, change, "-", palette.expected, palette.info, palette)?;
write_change(
writer,
change,
"-",
palette.expected,
palette.error,
palette,
)?;
}
similar::ChangeTag::Equal => {
write_change(writer, change, "|", palette.hint, palette.hint, palette)?;
Expand Down

0 comments on commit b955de0

Please sign in to comment.