vscode-go
vscode-go copied to clipboard
Respecting `vscode` exclude directives.
Is your feature request related to a problem? Please describe.
I am having directories in my project consisting of different open-source projects, and I would like gopls
not to even look in that direction (as my laptop don't like too much attention to CPU and become pan really fast).
Describe the solution you'd like
vscode-go
has few related settings (files.exclude
, search.exclude
, files.watcherExclude
) maybe vacode-go extension can utilize it?
{
"files.exclude": {
".sandbox/repos-*": true
},
"search.exclude": {
".sandbox/repos-*": true
},
"files.watcherExclude": {
".sandbox/repos-*": true
}
}
Describe alternatives you've considered
May be we can have additional exclude options? (i.e go.exclude
)
Additional context I am working on linter, and running tests on live examples quite fast, my laptop fan isn't a fun of it.
Thanks for the issue.
We've been discussing this problem, and agree that we should do something in this direction.
You may already be aware of the gopls directoryFilters
option:
https://github.com/golang/tools/blob/master/gopls/doc/settings.md#directoryfilters-string
You should be able to use that to filter out the directories in question.
We've been debating whether to set a default directoryFilters
and/or whether to honor .gitignore'd directories. Considering vscode exclude directives is another option.
@findleyr indeed I miss this setting while thinking about how to solve the problem. might need to refresh my knowledge of gopls
configuration options.
Depending on the outcome of golang/go#46438, we might be able to automatically set directoryFilters based on vscode settings.
@firelizzard18 should we consider adding a similar filter for test explorer?
Yes, I think we should
Change https://golang.org/cl/351172 mentions this issue: src/goTest: support excluding packages and files
The linked issue (https://golang.org/cl/351172) mentions that implementation of this feature has been abandoned due to @firelizzard18 not having the time to refactor the initial PR. Is this something that is being worked on currently by any chance? Is this something that I could help push forward? I mentioned a possible solution that seems quite trivial to implement in a separate issue: https://github.com/golang/vscode-go/issues/2504#issuecomment-1478165931. If this is something that is of interest, I can help with the PR.
@greenstatic AFAIK no one is working on this. I have no problem with someone taking this over. As you say, skipping specific folders while walking is pretty easy. Your go.testExplorer.walk.exclude
isn't substantially different from my go.testExplorer.exclude
.
The complications start showing up when you look at how the driver should behave when settings are changed. As a user I would be rather frustrated if I had to reload VSCode any time I wanted to change the set of excluded paths. If we're going to have a better experience than that, simply skipping paths during walk is not sufficient; you also need to update the tree and potentially rescan some paths when the setting is changed. Of course you could throw away the entire test item tree and rescan it, but that would not perform well, especially for large projects. Plus that could throw away other resources associated with tests, such as CPU/memory profiles, which would add to the frustration.
Thus the vast majority of the complexity comes down to intelligently updating the test item tree when the exclusion list is updated. In my CL, I compare the old list to the new list to generate a diff. For added paths, I look for test items in those paths and destroy them. For removed paths, I track paths that were excluded and rescan them.