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
This commit is contained in:
@@ -1264,12 +1264,13 @@ impl Flag for Count {
|
|||||||
}
|
}
|
||||||
fn doc_long(&self) -> &'static str {
|
fn doc_long(&self) -> &'static str {
|
||||||
r"
|
r"
|
||||||
This flag suppresses normal output and shows the number of lines that match the
|
This flag suppresses normal output and shows the number of lines that match
|
||||||
given patterns for each file searched. Each file containing a match has its
|
the given patterns for each file searched. Each file containing a match has
|
||||||
path and count printed on each line. Note that unless \flag{multiline}
|
its path and count printed on each line. Note that unless \flag{multiline} is
|
||||||
is enabled, this reports the number of lines that match and not the total
|
enabled and the pattern(s) given can match over multiple lines, this reports
|
||||||
number of matches. In multiline mode, \flag{count} is equivalent to
|
the number of lines that match and not the total number of matches. When
|
||||||
\flag{count-matches}.
|
multiline mode is enabled and the pattern(s) given can match over multiple
|
||||||
|
lines, \flag{count} is equivalent to \flag{count-matches}.
|
||||||
.sp
|
.sp
|
||||||
If only one file is given to ripgrep, then only the count is printed if there
|
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
|
is a match. The \flag{with-filename} flag can be used to force printing the
|
||||||
|
|||||||
Reference in New Issue
Block a user