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

search.exclude does not work for searching symbols across a workspace #46718

Closed
imdadahad opened this issue Mar 27, 2018 · 48 comments · Fixed by #192798
Closed

search.exclude does not work for searching symbols across a workspace #46718

imdadahad opened this issue Mar 27, 2018 · 48 comments · Fixed by #192798
Assignees
Labels
feature-request Request for new features or functionality workspace-symbols
Milestone

Comments

@imdadahad
Copy link

  • VSCode Version: Code Insiders Version 1.22.0-insider (1.22.0-insider)

Steps to Reproduce:

  1. Open a javascript project with a node_modules folder (couple packages installed)
  2. Search for a symbol across the project
  3. It will show results from the node_modules directory even if you have added the following your user/workspace settings:
"**/node_modules": true,
"node_modules": true
@vscodebot
Copy link

vscodebot bot commented Mar 27, 2018

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@roblourens
Copy link
Member

Is the "Use Exclude Settings and Ignore Files" button toggled on? (bottom right)

image

@roblourens roblourens added the info-needed Issue requires more information from poster label Mar 28, 2018
@imdadahad
Copy link
Author

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.

image

image

As shown it seems to retrieve results from node_modules despite having included the following in search.exclude:

"**/node_modules": true,
"node_modules": true

@roblourens
Copy link
Member

roblourens commented Mar 28, 2018

Those settings don't impact symbol search. Not sure whether symbol search is supposed to include node_modules stuff @mjbvz

@roblourens roblourens assigned mjbvz and unassigned roblourens Mar 28, 2018
@imdadahad
Copy link
Author

Oh really, would've thought anything that included node_modules would raise alarm bells given that indexing that folder is super slow. It would explain why it's noticeably slower to search for a symbol compared to Sublime.

@mjbvz
Copy link
Collaborator

mjbvz commented Apr 2, 2018

@imdadahad Do you have a jsconfig.json file? If not, try creating a simple one at the root of your project:

{
    "compilerOptions": {
        "target": "ES6"
    },
    "exclude": [
        "node_modules",
        "**/node_modules/*"
    ]
}

This should exclude node_modules files from symbol search

@vscodebot vscodebot bot removed the insiders label Apr 5, 2018
@imdadahad
Copy link
Author

Yes, I have this already.

@priezz
Copy link

priezz commented Aug 8, 2018

I have exactly the same issue. Results from 'node_modules' are shown when doing the symbol search. How to exclude specific directories?

@imdadahad
Copy link
Author

Any update on this, curious to know whether it's an actual bug/issue with config maybe?

@dkozickis
Copy link

dkozickis commented Oct 29, 2018

Any update please?
Same behavior on VSCode 1.28.2 / Windows 7

React TS project, trying to search for store symbol (part of application), I get following suggestions, with a million suggestion from node_modules, the store I'm looking for actually being on 8th place.

image

My settings.json

"search.exclude": {
    "**/node_modules": true,
    "**/bower_components": true
  },

@bernatfortet
Copy link

Any updates on this?
Searching workspace symbols is an amazing feature but seeing all the stuff from node_modules makes it less usable.

Thanks!

@dkozickis
Copy link

@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.exclude settings to filter the results for symbol search.

getWorkspaceSymbols is what supplies symbols data to the Quick search

https://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 TypeScriptWorkspaceSymbolProvider

https://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 results array 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:

  1. Quick Open symbol search does not filter the results based on VSCode search config
  2. Not a bug - a "feature"

I'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 openSymbolHandler

https://github.com/Microsoft/vscode/blob/29fe3f317ffa513746f456ee6026796638ada21a/src/vs/workbench/parts/search/browser/openSymbolHandler.ts#L136

Should it read from same search config 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.

@dkozickis
Copy link

@mjbvz @roblourens

A kind ping/reminder - if you could have a look and provide direction/comment?

@roblourens
Copy link
Member

Sorry I don't know what the intent is or whether this has been considered, @mjbvz?

@dkozickis
Copy link

A kind ping @mjbvz :)

@mjbvz mjbvz assigned roblourens and mjbvz and unassigned mjbvz Dec 3, 2018
@mjbvz mjbvz removed the info-needed Issue requires more information from poster label Dec 3, 2018
@mjbvz
Copy link
Collaborator

mjbvz commented Dec 3, 2018

@roblourens I feel workspace search should probably respect search.exclude but I don't think TS should be the one to determine this. If we to enable this, one option is to:

  • Make VS Code filter the returned results.
  • And also encourage providers to consult the search.exclude so that they don't return results that will be filtered out

@mjbvz mjbvz added feature-request Request for new features or functionality workspace-symbols labels Dec 3, 2018
@roblourens
Copy link
Member

Yeah if there is a max result count, then the provider definitely has to do the filtering. Hopefully eliminating results saves more time than it costs to do the glob matching.

@dwelle
Copy link

dwelle commented May 7, 2020

@bpasero

should have made clear, this requires the new quick open to be used, not the old one. The new is F1 > Quick Access > #. It will be enabled by default over coming days.

Instructions unclear. I don't have any Quick Access in latest insiders.

@bpasero
Copy link
Member

bpasero commented May 8, 2020

I should have posted here, the feature was pulled out, currently search.exclude is NOT being used for workspace symbol search.

@peterldowns
Copy link

peterldowns commented May 11, 2020

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.

@samuliasmala
Copy link

Is there any workarounds to exclude node_modules from Go To Symbol in Workspace? Now the feature is not very useful when you have a large amoun to packages installed in the project.

@kbysiec
Copy link

kbysiec commented Jul 10, 2020

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.

@adesnmi
Copy link

adesnmi commented Sep 13, 2020

Does anybody know the status of this?

@ddadon10
Copy link

+1 on this, I would to be able to exclude folder from symbol search

@CarinaChenot
Copy link

CarinaChenot commented Dec 13, 2020

+1 as well, the symbol search feature is not really usable as it is without being able to exclude node_modules from results

@ZeWaka
Copy link

ZeWaka commented Mar 24, 2021

bumping this, this is extremely annoying for JS projects we bootstrap in

@imdadahad
Copy link
Author

Would've had more luck buying BTC than having this resolved 😒

P.S. Still using PyCharm...

@timlau
Copy link

timlau commented Jul 3, 2021

Any news on this one ?
(**/build/** in seach exclude )
vscoude_symbol_search

@nvthuong1996
Copy link

I would to be able to exclude folder from symbol search

@CasualEngineerZombie
Copy link

It appears to have occurred as a result of the installation of a strange extension. I was able to remedy the issue by disabling all of the extensions one by one.

@selrond
Copy link
Contributor

selrond commented Dec 9, 2021

I'd also love to see this implemented, as many others before me.
Although it's been 2 years since @dkozickis broke it down, it seems like a low-hanging fruit that’d bring great value.

@mjbvz could you provide some insight into this?

@selrond
Copy link
Contributor

selrond commented Dec 9, 2021

If it’s reasonable for a first-time contributor to this repo, I’d try my hand at it

@alexn-s
Copy link

alexn-s commented Jan 30, 2022

are there any news on this subject?
i think its an important feature for vscode

@EcksDy
Copy link

EcksDy commented Feb 1, 2022

Goto symbol is unusable when it's showing results from dist/out/nodemodules etc.
Will this setting be implemented?

@imdadahad

This comment was marked as spam.

@mitsukuri

This comment was marked as spam.

@timbrownsf

This comment was marked as off-topic.

@microsoft microsoft locked and limited conversation to collaborators Mar 8, 2022
@mjbvz
Copy link
Collaborator

mjbvz commented Mar 8, 2022

I'm locking this issue since there have not been any constructive comments in quite a while

If you're interested in fixing this, please open a new issue that proposes what the fix would look like at a high level. If that looks good, then we can move on to an implementation

@mjbvz mjbvz added this to the Backlog milestone Dec 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality workspace-symbols
Projects
None yet