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.
Please sign in to leave a comment.
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'
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.
>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
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.
Please use 'In project' scope - it doesn't included excluded directories and libraries. Or, use 'Scope' + 'Project files'
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.
Find in path defaults to 'In Directory' for me.. how do you change the default to be 'in project'?
the dialog opens with last used scope preselected (as a result of fixing https://youtrack.jetbrains.com/issue/IDEA-87037).
Why does filter.vue.html appears in the search even though it's from an excluded dir?
Ok this has just started happening, randomly, after 10 years of using IntelliJ. Matches from EXCLUDED folders are now showing up in search results. This makes the entire feature unusable as there's now 100 matches of clutter for each valid result.
Can't tell you how annoying this is. What has happened? What is the fix?
Yep, just started happening randomly after using for a few years also. After searching for a workaround the only way is to painstakingly select every src folder.
If caches invalidation doesn't help, try deleting and re-creating .idea folder
Thanks for the help Elena. Unfortunately the cache invalidation didn't help nor did renaming the .idea folder.
Same issue here for over a year (IntelliJ IDEA Ultimate, Rider), I keep getting log and build files from the `target` directory in the case of IntelliJ and occasionally object files from Rider. There's an option "Show Excluded Files", which is on by default, but turning it off doesn't exclude anything.
The only workaround I found is adding "target" or "bin" to Settings/Editor/File Types/Ignored Files and Folders, but that seems heavy handed.
Behavior definitely has changed. I have a lot of "git ignored" html files being generated as part of my e2e tests and now every search I do includes them. Files are scattered across the modules as each module generates them.
Is it possible to have an option to remove "git ignored" files from search results? Really hard to work with the project now. I ended up writing a script to remove those html files every time.
Also with new async search, the result window is not being focused until the search is completed in background. That breaks the keyboard flow :(
>Is it possible to have an option to remove "git ignored" files from search results?
No way; please follow https://youtrack.jetbrains.com/issue/IDEA-145160/Gitignore-based-custom-filter-for-Find-in-Files for updates.
This could be solved by automatically marking all ignored files as excluded - IDEA-140714 , but the latter is not implemented