summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2020-10-17 18:55:44 -0400
committerAndrew Gallant <jamslam@gmail.com>2020-10-17 18:55:44 -0400
commit2b1637d1db5f8d20f417db11e3ef157b02556429 (patch)
tree9cbef80a7ed6ab3bab7b827cc929364b9572b3d0
parent6301e20ee460d11e0d81e2efacd8c52d2e231c0f (diff)
doc: clarify how -S/--smart-case works
Whether or not smart case kicks in can be a little subtle in some cases. So we document the specific conditions in which it applies. These conditions were taken directly from the public API docs of the `grep-regex` crate: https://docs.rs/grep-regex/0.1.8/grep_regex/struct.RegexMatcherBuilder.html#method.case_smart Fixes #1708
-rw-r--r--crates/core/app.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/crates/core/app.rs b/crates/core/app.rs
index 056dc33f..9785bccb 100644
--- a/crates/core/app.rs
+++ b/crates/core/app.rs
@@ -2634,6 +2634,15 @@ fn flag_smart_case(args: &mut Vec<RGArg>) {
Searches case insensitively if the pattern is all lowercase. Search case
sensitively otherwise.
+A pattern is considered all lowercase if both of the following rules hold:
+
+First, the pattern contains at least one literal character. For example, 'a\\w'
+contains a literal ('a') but just '\\w' does not.
+
+Second, of the literals in the pattern, none of them are considered to be
+uppercase according to Unicode. For example, 'foo\\pL' has no uppercase
+literals but 'Foo\\pL' does.
+
This overrides the -s/--case-sensitive and -i/--ignore-case flags.
"
);