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

Enable "smart case" for search #41119

Closed
roblourens opened this issue Jan 4, 2018 · 2 comments
Closed

Enable "smart case" for search #41119

roblourens opened this issue Jan 4, 2018 · 2 comments
Assignees
Labels
feature-request Request for new features or functionality search Search widget and operation issues verification-needed Verification of issue is requested verified Verification succeeded

Comments

@roblourens
Copy link
Member

roblourens commented Jan 4, 2018

"Smart case" is a ripgrep feature that will handle a query as case-sensitive if it contains uppercase characters, and case-insensitive if it doesn't.

For example, a document contains

asdf
asdF

With "smart case" enabled, the query asdf matches line 1 and line 2. And the query asdF only matches line 2.

It also works for regular expressions. The regex query asd\S matches line 1 and line 2. The query asd[A-Z] only matches line 2.

We should introduce a setting, search.smartCase or editor.find.smartCase. This is easy to hook up for ripgrep, but we also need to implement it for when results are provided by the editor, and for when ripgrep is not used. This is easy for non-regex queries. For regex queries, ripgrep previously attempted to tell whether the regex would match any uppercase characters. But this had unintended consequences, like \w triggering case-sensitivity, so now it only checks whether the regex text has any unescaped uppercase characters (BurntSushi/ripgrep#717). Fortunately this is easy for us to match.

  • Does this make sense for editor find or just search?
  • If both, is it a problem that search is respecting some editor.find settings but not all?

cc @rebornix

Alternately, the "case sensitive" toggle button could be a 3-mode switch which also can enable smart case.

@roblourens roblourens added feature-request Request for new features or functionality search Search widget and operation issues labels Jan 4, 2018
@roblourens roblourens added this to the December 2017/January 2018 milestone Jan 4, 2018
@roblourens roblourens self-assigned this Jan 4, 2018
@roblourens roblourens removed this from the December 2017/January 2018 milestone Jan 4, 2018
@roblourens roblourens added the verification-needed Verification of issue is requested label Jan 4, 2018
@octref octref added the verified Verification succeeded label Jan 31, 2018
@octref
Copy link
Contributor

octref commented Jan 31, 2018

See #42684 for an issue.
I think this should go to editor find too. Vim has this on by default.
One thing would be great: When this setting is on, whenever you type in the first uppercase char it toggles the Match Case icon (but later people can still toggle it off).

@roblourens
Copy link
Member Author

I agree, we had talked about more UI for that. Just filed #42687

@vscodebot vscodebot bot locked and limited conversation to collaborators Feb 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality search Search widget and operation issues verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

2 participants