From 2b1637d1db5f8d20f417db11e3ef157b02556429 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Sat, 17 Oct 2020 18:55:44 -0400 Subject: [PATCH] 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 --- crates/core/app.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/core/app.rs b/crates/core/app.rs index 056dc33..9785bcc 100644 --- a/crates/core/app.rs +++ b/crates/core/app.rs @@ -2634,6 +2634,15 @@ fn flag_smart_case(args: &mut Vec) { 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. " );