internal/lsp: add support for go.work files in file watching

This will allow us to add more support for the workspace proposal.

Change-Id: Ie557121afe0c16989ac176dc9246d82661a20c44
Reviewed-on: https://go-review.googlesource.com/c/tools/+/341811
Trust: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
Rebecca Stambler 2021-08-12 15:34:34 -04:00
parent 8fae06a885
commit 45389f592f
1 changed files with 5 additions and 3 deletions

View File

@ -787,13 +787,15 @@ func (s *snapshot) getWorkspacePkgPath(id packageID) packagePath {
return s.workspacePackages[id]
}
const fileExtensions = "go,mod,sum,work,tmpl"
func (s *snapshot) fileWatchingGlobPatterns(ctx context.Context) map[string]struct{} {
// Work-around microsoft/vscode#100870 by making sure that we are,
// at least, watching the user's entire workspace. This will still be
// applied to every folder in the workspace.
patterns := map[string]struct{}{
"**/*.{go,mod,sum}": {},
"**/*.*tmpl": {},
fmt.Sprintf("**/*.{%s}", fileExtensions): {},
"**/*.*tmpl": {},
}
dirs := s.workspace.dirs(ctx, s)
for _, dir := range dirs {
@ -807,7 +809,7 @@ func (s *snapshot) fileWatchingGlobPatterns(ctx context.Context) map[string]stru
// TODO(rstambler): If microsoft/vscode#3025 is resolved before
// microsoft/vscode#101042, we will need a work-around for Windows
// drive letter casing.
patterns[fmt.Sprintf("%s/**/*.{go,mod,sum,tmpl}", dirName)] = struct{}{}
patterns[fmt.Sprintf("%s/**/*.{%s}", dirName, fileExtensions)] = struct{}{}
}
// Some clients do not send notifications for changes to directories that