Add vendor directory to find scope

I've defined some custom scopes to use in "Find in Files". When I add Composer's vendor directory with either of the Include buttons, I only get the bin subdirectory and the autoload.php file, but none of the actual libraries. They don't even show in the bottom pane:

Is this how it's meant to behave? Is there a way to be able to search in libraries when using scopes?

0
5 comments

Hi there,

Composer packages (folders) from vendor folder are automatically marked as Excluded (controlled by "Settings/Preferences | PHP | Composer | Add packages as libraries" option) and then re-added back via "Include Paths" mechanic. You can see all Excluded folders at "Settings/Preferences | Directories".

This way it allows to exclude 3rd party code so it's not treated as your own (so it does not warn about TODOs/code style/unknown class/other inspection) but at the same time still allows to index them and be available in a code completion.

You cannot reference Excluded folders when making a new custom Scope.

If you want to use Find in Files to perform search in such vendor folders, please use "Scope" option and select predefined "Project and Libraries" entry:

or use "Directory" option and the actual path to the vendor folder (will search only there):

0

The problem is that there're several directories that I need to include or exclude depending on what I'm searching and I thought scopes would ease that, but they're not the right tool. Thank you very much!

0

Hi there,

Try this: select all desired folders in the Project View panel and then invoke Find in File using keyboard shortcut (not using the main menu). This way it should use special "Selected Files" scope that I expect to work in a similar way to how specifying an exact Directory works (2nd screenshot from the prev message).

I have not tested this with such excluded vendor folders... so it's just a guess / idea worth checking.

0

I think I'm following your instructions correctly but it defaults to "Directory" with the first directory selected. I can switch manually to "Scope/ Selected files and & directories" but it's pretty much ignoring my selection.

No worries, at least I'm more aware of how scope search works.

0

I think I'm following your instructions correctly but it defaults to "Directory" with the first directory selected.

Yes. I though it would select the different/right scope automatically...

I can switch manually to "Scope/ Selected files and & directories" but it's pretty much ignoring my selection.

Just tried -- works for me. But you have to manually select the "Scope" and then "Selected directories" there.

What I did:

  1. Searched for "doctrine/lexer" in this typical Laravel 8.x project in the whole project first (point #4) and opened all results in the tool window (point #5 -- 27 results)
  2. Then went to vendor and selected 3 custom folders (point #3) -- if I expand them then will have that light yellow background (just like "composer" folder above it has, just like background in Find in Files results background) The light yellow by default (using standard light theme) indicates Excluded / out-of-project files and folders (the color can be changed/disabled at "Settings/Preferences | Appearance & Behavior | File Colors")
  3. Invoked Find in Files using keyboard (that's IMPORTANT otherwise the selection can be lost or "Selected xxx" entry be absent) and then manually changed to Scope and Selected directories (point #1)
  4. The search for the same text "doctrine/lexer" now produces only 4 matches (point #2). Note: 2 matches are on the same line and therefore only 3 lines in the results.

 

0

Please sign in to leave a comment.