From c45ec16360870bba60505489fb745ad245075a86 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Mon, 22 Sep 2025 22:00:15 -0400 Subject: [PATCH] doc: clarify `--multiline --count` Specifically, it is only equivalent to `--count-matches` when the pattern(s) given can match over multiple lines. We could have instead made `--multiline --count` always equivalent to `--multiline --count-matches`, but this seems plausibly less useful. Indeed, I think it's generally a good thing that users can enable `-U/--multiline` but still use patterns that only match a single line. Changing how that behaves would I think be more surprising. Either way we slice this, it's unfortunately pretty subtle. Fixes #2852 --- crates/core/flags/defs.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/core/flags/defs.rs b/crates/core/flags/defs.rs index e9b05df..bbe1348 100644 --- a/crates/core/flags/defs.rs +++ b/crates/core/flags/defs.rs @@ -1264,12 +1264,13 @@ impl Flag for Count { } fn doc_long(&self) -> &'static str { r" -This flag suppresses normal output and shows the number of lines that match the -given patterns for each file searched. Each file containing a match has its -path and count printed on each line. Note that unless \flag{multiline} -is enabled, this reports the number of lines that match and not the total -number of matches. In multiline mode, \flag{count} is equivalent to -\flag{count-matches}. +This flag suppresses normal output and shows the number of lines that match +the given patterns for each file searched. Each file containing a match has +its path and count printed on each line. Note that unless \flag{multiline} is +enabled and the pattern(s) given can match over multiple lines, this reports +the number of lines that match and not the total number of matches. When +multiline mode is enabled and the pattern(s) given can match over multiple +lines, \flag{count} is equivalent to \flag{count-matches}. .sp If only one file is given to ripgrep, then only the count is printed if there is a match. The \flag{with-filename} flag can be used to force printing the