Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve --smart-case once and for all #851

Closed
BurntSushi opened this issue Mar 10, 2018 · 0 comments
Closed

improve --smart-case once and for all #851

BurntSushi opened this issue Mar 10, 2018 · 0 comments
Labels
enhancement An enhancement to the functionality of the software. libripgrep An issue related to modularizing ripgrep into libraries.
Milestone

Comments

@BurntSushi
Copy link
Owner

We should improve the --smart-case flag to be perfect or nearly perfect at least. The regex-syntax crate rewrite now has a more detailed AST, which permits us to handle cases like [A-Z] and \p{Ll} differently. In particular, I propose:

When the --smart-case flag is given, ripgrep chooses to match case insensitively if and only if there is at least one literal character in the pattern and that all such literals are not considered as uppercase. If the pattern contains no literals or at least one uppercase literal character, then normal case sensitive search is used.

Examples: abc, [a-z], abc\w and abc\p{Ll} are all searched case insensitively while aBc, [A-Z], aBc\w and \p{Ll} are searched case sensitively.

See also: #717 (comment)

cc @okdana

@BurntSushi BurntSushi added enhancement An enhancement to the functionality of the software. libripgrep An issue related to modularizing ripgrep into libraries. labels Mar 10, 2018
@BurntSushi BurntSushi added this to the libripgrep milestone Mar 10, 2018
BurntSushi added a commit that referenced this issue Mar 14, 2018
This commit removes the previous smart case detection logic and replaces
it with detection based on the regex AST. This particular AST is a faithful
representation of the concrete syntax, which lets us be very precise in
how we handle it.

Closes #851
BurntSushi added a commit that referenced this issue Mar 14, 2018
This commit removes the previous smart case detection logic and replaces
it with detection based on the regex AST. This particular AST is a faithful
representation of the concrete syntax, which lets us be very precise in
how we handle it.

Closes #851
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement to the functionality of the software. libripgrep An issue related to modularizing ripgrep into libraries.
Projects
None yet
Development

No branches or pull requests

1 participant