Excluded folders being indexed for search

WebStorm 2017.1.2
Build #WS-171.4249.40, built on April 25, 2017
Licensed to Pitney Bowes / Richard Collette
You have a perpetual fallback license for this version
Subscription is active until March 22, 2018
JRE: 1.8.0_112-release-736-b21 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.12.4

I have excluded folders and marked files as text.   Yet these excluded items are showing up in search results.   In the case of excluded folders, code lines appear in the results in yellow.  In the case of excluded files (those marked as text), the code file names show up on the right in a light gray color.

So clearly the search is aware of something distinctive about these files yet it is indexing them and showing them in the results anyway.

Is there a preferences or setting related to this?   I've cleared the indexes and restarted but that didn't work.    I search on "search" and "index" in the preferences and couldn't find anything.




8 comments
Comment actions Permalink

Only those node_modules that are not listed in project's package.json file are actually excluded, all direct dependencies listed there are marked as a JavaScript library and are indexed to make it possible to resolve and autocomplete methods from them.

Also, files marked as plain text do not participate in completion/error highlighting/etc., but are still included in files index - as text search is also based on indexing.

To fully exclude the node_modules folder from the project go to Preferences | Languages & Frameworks | JavaScript | Libraries and uncheck node_modules in the list.
Please note that as a result many library methods in you app's code will be marked as unresolved.

Also, as far as I can see from your screenshot, you are using 'Directory' scope for your search - but this scope does include excluded directories if the excluded folder is selected as a directory.

Please use 'In project' scope - it doesn't included excluded directories and libraries. Or, use 'Scope' + 'Project files'

0
Comment actions Permalink

Thank you for the reply.

So how can I exclude a generated (built) file from indexing?  I don't recall this always being the behavior in WebStorm.   Very rarely do I need to search in generated files (unless I specifically open them).

Likewise, it wasn't always the behavior that searches would result in excluded folder content, even for node_modules, coming up in the results.  I get that the IDE may find this useful for code completion or other internals but it's only useful to a dev when I specifically want to search in node modules, by doing a directory search starting on the node_modules folder.   I'm definitely going to open a bug for this one.

 

0
Comment actions Permalink

>So how can I exclude a generated (built) file from indexing? 

you can either mark its parent directory as excluded or add this file to ignored files in Preferences | Editor | File Types

 

>Likewise, it wasn't always the behavior that searches would result in excluded folder content, even for node_modules, coming up in the results

excluded folders were always searched when using 'directory' scope; and, as i wrote, not all files in node_modules are actually excluded - files added to JavaScript libraries are always indexed for completion, even if their parent folder is excluded

0
Comment actions Permalink

I have the exact same "issue". I see the importance of not excluding node_modules because the IDE needs to "resolve and autocomplete methods from them".

But wouldn't it be nice if IntelliJ / WebStorm was able to index those modules but exclude them from the global search? I think 99% of all devs using the global search (find in path) feature only want to see results from their own code and not to search external modules. If I want to search within node_modules I specifically set "directory" as scope for the search (select "node_modules" and press CTRL+SHIFT+F).

I think this would make the life of most devs much easier and would serve the needs of the majority.

The same goes for the navigate -> file (CTRL+SHIFT+N). I don't want to have "node_module" files in this list because it's irrelevant in 99% of the cases.

2
Comment actions Permalink

Please use 'In project' scope - it doesn't included excluded directories and libraries. Or, use 'Scope' + 'Project files'

4
Comment actions Permalink

That's exactly what I use - "in project", which is default when opening the search / find in path.

I'm working with IntelliJ, which did not automatically recognize "node_modules" as a library. Just added it to JavaScript libraries and now everything is as expected.

0
Comment actions Permalink

Find in path defaults to 'In Directory' for me.. how do you change the default to be 'in project'?

0
Comment actions Permalink

the dialog opens with last used scope preselected (as a result of fixing https://youtrack.jetbrains.com/issue/IDEA-87037).

0

Please sign in to leave a comment.