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:
- Add the following setting to vscode
settings.json
:
{
"search.exclude": {
"**/var/folders/**": true
}
}
- Open some git diff editors from the source control panel.
- Use
workbench.action.quickOpen
. - Files inside
**/var/folders/**
still show in the search list:
The above also applies to **/.git/**": true
with workbench.action.openRecent
:
About this issue
- Original URL
- State: closed
- Created 5 months ago
- Reactions: 5
- Comments: 40 (30 by maintainers)
Commits related to this issue
- [Bug] /var/folders/** files can't be excluded from search (fix #203872) — committed to microsoft/vscode by bpasero 3 months ago
- [Bug] /var/folders/** files can't be excluded from search (fix #203872) (#208296) — committed to haykam821/vscode by bpasero 3 months ago
Thanks for being persistent about this issue, I am pushing 2 changes that I think will improve this today buggy behaviour:
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 anode_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 pathnode_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 fromnode_modules
folder.It should not matter to change the setting, I just indicated this for a clearer repro. What does matter is:
search.exclude
pattern would matchMaybe we should just hide some file patterns in the picker for Git, we already do that in other places:
https://github.com/microsoft/vscode/blob/92592894f724df264d4215d94a4f517b32021f1a/src/vs/platform/workspaces/electron-main/workspacesHistoryMainService.ts#L301-L304
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 settingsearch.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.