From 45389f592fe91a21327056ee2b429439583f2652 Mon Sep 17 00:00:00 2001 From: Rebecca Stambler Date: Thu, 12 Aug 2021 15:34:34 -0400 Subject: [PATCH] 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 gopls-CI: kokoro Run-TryBot: Rebecca Stambler TryBot-Result: Go Bot Reviewed-by: Robert Findley --- internal/lsp/cache/snapshot.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/lsp/cache/snapshot.go b/internal/lsp/cache/snapshot.go index 8978dfcf3d..dc235d6995 100644 --- a/internal/lsp/cache/snapshot.go +++ b/internal/lsp/cache/snapshot.go @@ -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