vscode: search.exclude does not work for searching symbols across a workspace
- VSCode Version: Code Insiders Version 1.22.0-insider (1.22.0-insider)
Steps to Reproduce:
- Open a javascript project with a node_modules folder (couple packages installed)
- Search for a symbol across the project
- It will show results from the
node_modulesdirectory even if you have added the following your user/workspace settings:
"**/node_modules": true,
"node_modules": true
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 91
- Comments: 48 (16 by maintainers)
Links to this issue
Commits related to this issue
- quick access - support exclude config for results (#46718) — committed to microsoft/vscode by bpasero 4 years ago
Sorry for the bump! But symbol search is quite painful without filtering out excluded libs. This is such a crucial feature that everybody uses, and so frequently.
Are there any PR’s in the pipeline addressing this?
Does anybody know the status of this?
Would’ve had more luck buying BTC than having this resolved 😒
P.S. Still using PyCharm…
Is there any workarounds to exclude
node_modulesfrom Go To Symbol in Workspace? Now the feature is not very useful when you have a large amoun to packages installed in the project.I was suffering the same and decided to develop an extension for easy navigation among workspace files and symbols. Hope it helps somebody.
It is fully customizable so the user can easily decide which folders are included/excluded from the currently opened workspace/project.
https://marketplace.visualstudio.com/items?itemName=kbysiec.vscode-search-everywhere
Enjoy.
@mjbvz, @roblourens (sorry to tag you both, just hoping to get some reply and direction)
Summary is at the bottom.
So, I’ve code dived a bit, finding is that Workbench search (Quick Open) or whatever anyone calls it, is not using
search.excludesettings to filter the results forsymbolsearch.getWorkspaceSymbolsis what suppliessymbolsdata to the Quick searchhttps://github.com/Microsoft/vscode/blob/c63c97c12848e85769e717209b73110e83c18ef6/src/vs/workbench/parts/search/common/search.ts#L57
Under the hood it calls TS Server ‘navto’ facilitated by
TypeScriptWorkspaceSymbolProviderhttps://github.com/Microsoft/vscode/blob/97c753fa1f9db7b39a91189807313a4bd344f45e/extensions/typescript-language-features/src/features/workspaceSymbols.ts#L23
Anyway, long story short, Symbol search results are pushed to
resultsarray around here (via OpenSymbolHandle)https://github.com/Microsoft/vscode/blob/850bbb275e648c75e3804f38f179642c7fa2d007/src/vs/workbench/parts/search/browser/openAnythingHandler.ts#L111-L113
And then are returned to Quick Open controller.
Summing up:
searchconfigI’d like to try my hand at adding this to VSCode, if maintainers can point me in the correct direction. What I’m thinking is implementing filtering in
openSymbolHandlerhttps://github.com/Microsoft/vscode/blob/29fe3f317ffa513746f456ee6026796638ada21a/src/vs/workbench/parts/search/browser/openSymbolHandler.ts#L136
Should it read from same
searchconfig or implement it’s own setting? E.g.search.filterSymbols(dunno)? Also - if this was designed this way from begging - maybe there’s some reasoning to it?Appreciate comments.
bumping this, this is extremely annoying for JS projects we bootstrap in
This is related to the Symbol search option (https://code.visualstudio.com/docs/editor/editingevolved#_open-symbol-by-name), not the find in all files as you’ve shown above.
As shown it seems to retrieve results from
node_modulesdespite having included the following insearch.exclude:I should have posted here, the feature was pulled out, currently
search.excludeis NOT being used for workspace symbol search.@imdadahad Do you have a jsconfig.json file? If not, try creating a simple one at the root of your project:
This should exclude node_modules files from symbol search
Any update on this, curious to know whether it’s an actual bug/issue with config maybe?
Any news on this one ? (
**/build/**in seach exclude )I think it makes sense for the language server plugins to be able to resolve those symbols, but also that when quick-searching for symbols, to allow users to say “i don’t want to be able to quick-resolve to symbols deep in my node_modules tree”. It’s useful to be able to find all the symbols in use in my project when jumping through and debugging stuff, but when i’m quick-opening I ALWAYS want to find a symbol that I have defined in my own project, not some deep library code.
If it’s reasonable for a first-time contributor to this repo, I’d try my hand at it
Am really running into this issue hard, especially for commonly used function/variable names. I would really appreciate the sorting functionality mentioned above as a fallback.
I think we should all just buy ETH while we’re waiting.
Let’s face it, this PR is staying in a bear market.
I’m having this issue as well; I can’t think of any reason why you wouldn’t want the symbols search to honor the search exclusions. I can’t find the symbols I’m looking for in my project because the results get spammed by node_modules and hit the max results limit.
Edit: Is there a way to order the search results to prioritize project symbols over type definitions and node_modules? My tsconfig has only the
srcfolder in the include directive, and node_modules is excluded. I would be happy if symbol search just used the tsconfig for narrowing search results even if it didn’t use the same settings as file searches.Yes, I have this already.
Is this fix slated for a specific release? Excited to get my hands on it!
Ok - thanks for clarifying. If you ask me what a language extension should do, then I would recommend to rely on a project config, not on vs code config, esp in the name of LSP and potentially different front ends
I have exactly the same issue. Results from ‘node_modules’ are shown when doing the symbol search. How to exclude specific directories?
Is the “Use Exclude Settings and Ignore Files” button toggled on? (bottom right)