summaryrefslogtreecommitdiffstats
path: root/crates/core/args.rs
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2021-05-30 21:36:35 -0400
committerAndrew Gallant <jamslam@gmail.com>2021-05-31 21:51:18 -0400
commitfc31aedcf3cae7a773c94a79775396759af10dd8 (patch)
tree71627aaa0397f1165e2ce214745df6dda2f99ce0 /crates/core/args.rs
parent578e1992fa21d3612d3e613d8869dbbb16e33cbe (diff)
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
Diffstat (limited to 'crates/core/args.rs')
-rw-r--r--crates/core/args.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/crates/core/args.rs b/crates/core/args.rs
index caa378bd..ca7d6069 100644
--- a/crates/core/args.rs
+++ b/crates/core/args.rs
@@ -777,6 +777,7 @@ impl ArgMatches {
.path(self.with_filename(paths))
.only_matching(self.is_present("only-matching"))
.per_match(self.is_present("vimgrep"))
+ .per_match_one_line(true)
.replacement(self.replacement())
.max_columns(self.max_columns()?)
.max_columns_preview(self.max_columns_preview())