mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-07-25 17:21:57 -07:00
printer: vimgrep now only prints one line
It turns out that the vimgrep format really only wants one line per match, even when that match spans multiple lines. We continue to support the previous behavior (print all lines in a match) in the `grep-printer` crate. We add a new option to enable the "only print the first line" behavior, and unconditionally enable it in ripgrep. We can do that because the option has no effect in single-line mode, since, well, in that case matches are guaranteed to span one line anyway. Fixes #1866
This commit is contained in:
@@ -917,10 +917,12 @@ rgtest!(r1866, |dir: Dir, mut cmd: TestCommand| {
|
||||
"test",
|
||||
]);
|
||||
|
||||
// vimgrep only wants the first line of each match, even when a match
|
||||
// spans multiple lines.
|
||||
//
|
||||
// See: https://github.com/BurntSushi/ripgrep/issues/1866
|
||||
let expected = "\
|
||||
test:1:1:foobar
|
||||
test:2:1:foobar
|
||||
test:3:1:foo quux
|
||||
test:3:5:foo quux
|
||||
";
|
||||
eqnice!(expected, cmd.stdout());
|
||||
|
Reference in New Issue
Block a user