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

Secondary search #118128

Open
meganrogge opened this issue Mar 4, 2021 · 7 comments
Open

Secondary search #118128

meganrogge opened this issue Mar 4, 2021 · 7 comments
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s) feature-request Request for new features or functionality search Search widget and operation issues
Milestone

Comments

@meganrogge
Copy link
Contributor

meganrogge commented Mar 4, 2021

I'd like to be able to search for something, for example ipad and then in the files which contain that term, search for something else, for example terminal.

IE find files which contain ____ && ____.

@roblourens
Copy link
Member

Do you want to search in the line with the match, and the surrounding lines, or anywhere in the file? If the first, try Search Editors.

@meganrogge
Copy link
Contributor Author

Anywhere in the file

@roblourens roblourens added feature-request Request for new features or functionality search Search widget and operation issues labels Mar 4, 2021
@roblourens roblourens added this to the Backlog Candidates milestone Mar 4, 2021
@meganrogge meganrogge reopened this Jun 15, 2021
@meganrogge meganrogge assigned meganrogge and unassigned roblourens Jun 15, 2021
@meganrogge
Copy link
Contributor Author

It would've saved me so much time to have this capability on 3 unique occasions today. Talked w @kieferrm and I hope to work on a PR for ripgrep in the coming iterations so that we have a:

SearchTerm1 && SearchTerm2 option

@roblourens
Copy link
Member

roblourens commented Jun 16, 2021

Could also be a good extension candidate using the (proposed) findTextInFiles API.

For your original case, it sounds like what I often use "files to include" for, when I want to search for the use of a term like ipad in some feature area like notebooks, I would use notebook or *Notebook* (note that it's case sensitive)

@ArturoDent
Copy link

ArturoDent commented Jul 2, 2021

I made an extension which applies a workaround by copying the current search results, regex-ing for the filenames, getting their relative paths and then putting those paths into the 'files to include` filter. Find and Transform.

Specifically Using the Search Results files in another search.

Use from the context menu, Command Palette or a keybinding like:

{
  "key": "alt+shift+f", 
  "command": "runInSearchPanel",   
  "args": {
    "find": "Second",                            // plus all the other args from the findInFiles command 
    "replace": "Third",
    "filesToInclude": "${resultsFiles}",   // !!
    "triggerSearch": true                
  },
	"when": "hasSearchResult"      // I suggest this but it isn't mandatory
}

There are other ways to use the ${resultsFiles} variable as well. Such as in the find-and-transform.searchInResults command where it is automatically applied.

Using this keybinding:

  {
    "key": "alt+z",
    "command": "runInSearchPanel",
    "args": {
      "filesToInclude": "${resultsFiles}",
      "triggerSearch": true,
    }
  },

Demo:

searchWithoutSelection2

[Since the context menu item for this really belongs in the Search results context menu but that is not currently exposed to extensions, I am going to file an issue requesting it. See https://github.com//issues/127896]

@osortega
Copy link
Contributor

This is a duplicate of #197634
Closing

/duplicate

@vs-code-engineering vs-code-engineering bot added the *duplicate Issue identified as a duplicate of another issue(s) label Dec 20, 2024
@gjsjohnmurray
Copy link
Contributor

@osortega I disagree about this being a duplicate. That one is about tree filtering. And anyway it's locked so unavailable for discussion.

@meganrogge meganrogge reopened this Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
*duplicate Issue identified as a duplicate of another issue(s) feature-request Request for new features or functionality search Search widget and operation issues
Projects
None yet
Development

No branches or pull requests

7 participants
@roblourens @gjsjohnmurray @meganrogge @andreamah @ArturoDent @osortega and others