mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-07-25 17:21:57 -07:00
cli: fix bug where last byte was stripped
In an effort to strip line terminators, we assumed their existence. But a pattern file may not end with a line terminator, so we shouldn't unconditionally strip them. We fix this by moving to bstr's line handling, which does this for us automatically.
This commit is contained in:
@@ -705,3 +705,14 @@ rgtest!(r1203_reverse_suffix_literal, |dir: Dir, _: TestCommand| {
|
||||
let mut cmd = dir.command();
|
||||
eqnice!("153.230000\n", cmd.arg(r"\d\d\d000").arg("test").stdout());
|
||||
});
|
||||
|
||||
// See: https://github.com/BurntSushi/ripgrep/issues/1259
|
||||
rgtest!(r1259_drop_last_byte_nonl, |dir: Dir, mut cmd: TestCommand| {
|
||||
dir.create("patterns-nonl", "[foo]");
|
||||
dir.create("patterns-nl", "[foo]\n");
|
||||
dir.create("test", "fz");
|
||||
|
||||
eqnice!("fz\n", cmd.arg("-f").arg("patterns-nonl").arg("test").stdout());
|
||||
cmd = dir.command();
|
||||
eqnice!("fz\n", cmd.arg("-f").arg("patterns-nl").arg("test").stdout());
|
||||
});
|
||||
|
Reference in New Issue
Block a user