mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-07-26 01:31:57 -07:00
printer: --only-matching works with --replace
When -o/--only-matching is used with -r/--replace, the replacement works as expected. This is not a breaking change because the flags were previously set to conflict.
This commit is contained in:
committed by
Andrew Gallant
parent
363a4fa9b7
commit
f887bc1f86
@@ -266,6 +266,20 @@ but Watson, Doctor has to have it taken out for him and dusted,
|
||||
assert_eq!(lines, expected);
|
||||
});
|
||||
|
||||
sherlock!(replace_with_only_matching, "of (\\w+)",
|
||||
|wd: WorkDir, mut cmd: Command| {
|
||||
cmd.arg("-o").arg("-r").arg("$1");
|
||||
let lines: String = wd.stdout(&mut cmd);
|
||||
let expected = "\
|
||||
this
|
||||
detective
|
||||
luck
|
||||
straw
|
||||
cigar
|
||||
";
|
||||
assert_eq!(lines, expected);
|
||||
});
|
||||
|
||||
sherlock!(file_types, "Sherlock", ".", |wd: WorkDir, mut cmd: Command| {
|
||||
wd.create("file.py", "Sherlock");
|
||||
wd.create("file.rs", "Sherlock");
|
||||
|
Reference in New Issue
Block a user