printer: trim line terminator before doing replacements

This is basically the same bug as #1401, but applied to replacements
instead of --only-matching.

Fixes #1739
This commit is contained in:
Andrew Gallant
2021-05-31 19:52:26 -04:00
parent af8b27ffae
commit fbb2cfed28
3 changed files with 16 additions and 1 deletions

View File

@@ -945,6 +945,13 @@ rgtest!(r1638, |dir: Dir, mut cmd: TestCommand| {
eqnice!("foo:1:1:x\n", cmd.arg("--column").arg("x").stdout());
});
// See: https://github.com/BurntSushi/ripgrep/issues/1739
rgtest!(r1739_replacement_lineterm_match, |dir: Dir, mut cmd: TestCommand| {
dir.create("test", "a\n");
cmd.args(&[r"-r${0}f", r".*", "test"]);
eqnice!("af\n", cmd.stdout());
});
// See: https://github.com/BurntSushi/ripgrep/issues/1765
rgtest!(r1765, |dir: Dir, mut cmd: TestCommand| {
dir.create("test", "\n");