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

--smart-case doesn't work with --regexp/-w #199

Closed
alejandro5042 opened this issue Oct 28, 2016 · 2 comments
Closed

--smart-case doesn't work with --regexp/-w #199

alejandro5042 opened this issue Oct 28, 2016 · 2 comments
Labels
bug A bug.

Comments

@alejandro5042
Copy link
Contributor

Smart casing works great if you use --fixed-strings. However, once you use --regexp or -w, it falls apart:

For example, this code does not match "ToCsvFile" in any file.

rg --smart-case --regexp "\btocsvfile"

Same with -w. Doesn't work:

rg --smart-case -w "tocsvfile"

But begins matching with --ignore-case.

@alejandro5042
Copy link
Contributor Author

Version 0.2.3.

@BurntSushi BurntSushi added the bug A bug. label Oct 28, 2016
@BurntSushi
Copy link
Owner

This is indeed a bug. It's probably related to literal optimizations that are ignoring the smart case flag. For example, this works even though it's using a regex:

[andrew@Cheetah tmp] cat foo
ToCSVFile
tocsvfile
[andrew@Cheetah tmp] rg '^\p{Ll}+$' foo
2:tocsvfile
[andrew@Cheetah tmp] rg -S '^\p{Ll}+$' foo
1:ToCSVFile
2:tocsvfile

(Although, I wonder if making pure regexes case insensitive even when smart case is enabled is desirable. Maybe it should only activate if there's at least one literal byte? Not sure, but that's a separate issue I guess.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug.
Projects
None yet
Development

No branches or pull requests

2 participants