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

Implement case preservation in search as well #78397

Closed
roblourens opened this issue Aug 2, 2019 · 3 comments · Fixed by #79111
Closed

Implement case preservation in search as well #78397

roblourens opened this issue Aug 2, 2019 · 3 comments · Fixed by #79111
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
Milestone

Comments

@roblourens
Copy link
Member

In #9798 we implemented some support for preserving the match case while doing a find/replace. We need the same feature in search.

@roblourens roblourens added feature-request Request for new features or functionality search Search widget and operation issues labels Aug 2, 2019
@roblourens roblourens added this to the August 2019 milestone Aug 2, 2019
@skprabhanjan
Copy link
Contributor

skprabhanjan commented Aug 13, 2019

@roblourens , Can I work on this ?
If yes , Please help me understand what does same feature in search mean ( I understood the find/replace use case ).

@roblourens
Copy link
Member Author

Yes that would be great @skprabhanjan! I want the same button that supports the same "preserve case" logic, but when using search in the side bar. Here is basically what you need to do:

The original PR is here: #60311

  • Add the same button to the replace input that the find widget got
  • Add plumbing for a "preserve case" option that goes along with the "is regex" and "whole word" and other options
  • We compute the replace string for search here: and we need to take the "preserve case" option into consideration here too. So we need to use this same code:
    if (matches[0].toUpperCase() === matches[0]) {
    return this._state.staticValue.toUpperCase();
    } else if (matches[0].toLowerCase() === matches[0]) {
    return this._state.staticValue.toLowerCase();
    } else if (containsUppercaseCharacter(matches[0][0])) {
    return this._state.staticValue[0].toUpperCase() + this._state.staticValue.substr(1);
    } else {
    // we don't understand its pattern yet.
    return this._state.staticValue;
    }
    ideally copying it into a shared file so that find and search will use the same preserve case logic.

Should be relatively straightforward, let me know if that doesn't make sense.

@deitry
Copy link

deitry commented Aug 16, 2019

Case preservation is a great feature.
Just to be clear: would it work with editor.action.addSelectionToNextFindMatch / addSelectionToPreviousFindMatch? I use this actions a lot through keybindings and hope this feature will be supported there too.

Upd. I didn't realized that you meant search sidebar. So I guess it should be another feature request.

@roblourens roblourens added the verification-needed Verification of issue is requested label Aug 27, 2019
@RMacfarlane RMacfarlane added the verified Verification succeeded label Aug 27, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Oct 3, 2019
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

Successfully merging a pull request may close this issue.

5 participants