From 7d73f9f2baf0a60d9bd15187b6088ae87c914eb7 Mon Sep 17 00:00:00 2001 From: Linus789 Date: Thu, 6 May 2021 00:04:05 +0200 Subject: [PATCH 1/2] Do not print out path in preview --- src/input.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/input.rs b/src/input.rs index 674ca81..e9fdc01 100644 --- a/src/input.rs +++ b/src/input.rs @@ -78,7 +78,6 @@ impl App { let file = unsafe { memmap::Mmap::map(&File::open(path)?)? }; if self.replacer.has_matches(&file) { - println!("{}", path.display()); handle .write_all(&self.replacer.replace_preview(&file))?; } From 2b3b201c0a3ec94a1cc4706c9d5bd04a15be6d53 Mon Sep 17 00:00:00 2001 From: Linus789 Date: Thu, 6 May 2021 00:41:36 +0200 Subject: [PATCH 2/2] Fix test for replace_into_stdout, since color was added --- tests/cli.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/cli.rs b/tests/cli.rs index 5f767d6..7e34861 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -46,11 +46,14 @@ mod cli { let mut file = tempfile::NamedTempFile::new()?; file.write(b"abc123def")?; - #[rustfmt::skip] - sd().args(&["-p", "abc\\d+", "", file.path().to_str().unwrap()]) - .assert() - .success() - .stdout("def"); + sd().args(&["-p", "abc\\d+", "", file.path().to_str().unwrap()]) + .assert() + .success() + .stdout(format!( + "{}{}def", + ansi_term::Color::Green.prefix().to_string(), + ansi_term::Color::Green.suffix().to_string() + )); assert_file(file.path(), "abc123def");