vscode: [Bug] `/var/folders/**` files can't be excluded from search

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.85.2
  • OS Version: macOS 14

Steps to Reproduce:

  1. Add the following setting to vscode settings.json:
{
  "search.exclude": {
    "**/var/folders/**": true
  }
}
  1. Open some git diff editors from the source control panel.
  2. Use workbench.action.quickOpen.
  3. Files inside **/var/folders/** still show in the search list: image

The above also applies to **/.git/**": true with workbench.action.openRecent: image

Ref: https://stackoverflow.com/questions/75594649/make-vs-code-ignore-files-under-var-folders#comment137355992_75609216

About this issue

  • Original URL
  • State: closed
  • Created 5 months ago
  • Reactions: 5
  • Comments: 40 (30 by maintainers)

Commits related to this issue

Most upvoted comments

Thanks for being persistent about this issue, I am pushing 2 changes that I think will improve this today buggy behaviour:

  • when closing an editor, we apply the exclude rules to see if we should remove it from history
  • on startup we apply the exclude rules properly for editors that are not opened (somehow we did not, probably got lost some time ago)

All these issues aside, having to use “/var/folders/”: true to make step 3 work is already a strange thing, why doesn’t “**/var/folders”: true work?

I still think that its a bit confusing that you need to specify absolute glob patterns to be considered for history, but I am not sure how to address that: there are components that can deal fine with patterns such as **/node_modules, namely those that iterate the file system recursively going through folders: file search is doing that and the explorer is working like that too, hence these patterns work fine there. But we have expanded the use of these patterns to other places where we do not traverse the directory structure but rather have the full absolute path in hand to check.

@natewaddoups it may appear as such, but strictly speaking no: fulltext search and file search in quick open works by spawning an external tool (ripgrep) to find matches. It does so by recursively going over all folders. As such, a glob pattern like **/node_modules will make this tool stop recursing further down when it reaches a node_modules folder.

However, the “recently opened” section in quick open works differently: it just collects editors that were opened and a match is computed by looking at the full path. A glob pattern **/node_modules does not match on a path node_modules/foo/index.html (anywhere in VS Code, not just in this case).

In addition: our intent with the defaults was to exclude **/node_modules from searches, but not necessarily from the recently opened list. Changing how this pattern is interpreted is a change for all users that used to see their recently opened files from node_modules folder.

It should not matter to change the setting, I just indicated this for a clearer repro. What does matter is:

  • editors cannot be opened as a tab anywhere, including after restart. any opened tab will always show in recently opened even if a search.exclude pattern would match
  • once you close an editor, we do not filter it out in the current session immediately but only after a reload (arguably this is something we could reconsider)

As far as I can remember, search.exclude only applies to results returned from file search, not over history entries. You can disable history entries via setting search.quickOpen.includeHistory

Thing is, I really like having the files that I explicitly opened in the cmd+P list.

What I don’t like is that the cmd+P list includes temp files that “git difftool” implicitly opened (as a side-effect of viewing a diff).

The exclusion setting gives us a way to exclude files from the cmd+P list, but the history feature does not respect that setting. This creates an awkward user experience - as more times goes by, more temp files pollute the cmd+P list.