From 0abbfa5d31cd6db879f0fab51ed31473e9e7d877 Mon Sep 17 00:00:00 2001 From: Rohan Challa Date: Wed, 12 Feb 2020 16:42:17 -0500 Subject: [PATCH] internal/lsp: turn tempModfile flag on by default This change turns the tempModfile flag on by default in the master branch. Change-Id: If96369aee4e970421a80d5ff89385a38c7ccf0b2 Reviewed-on: https://go-review.googlesource.com/c/tools/+/219225 Run-TryBot: Rohan Challa TryBot-Result: Gobot Gobot Reviewed-by: Rebecca Stambler --- internal/lsp/cache/view.go | 4 ++-- internal/lsp/lsp_test.go | 1 - internal/lsp/source/options.go | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/internal/lsp/cache/view.go b/internal/lsp/cache/view.go index a1baf9288b..21066992b7 100644 --- a/internal/lsp/cache/view.go +++ b/internal/lsp/cache/view.go @@ -591,8 +591,8 @@ func (v *view) setBuildInformation(ctx context.Context, folder span.URI, env []s // check if the view has a valid build configuration. v.hasValidBuildConfiguration = checkBuildConfiguration(v.goCommand, v.realMod, v.folder, v.gopath) - // The user has disabled the use of the -modfile flag. - if !modfileFlagEnabled { + // The user has disabled the use of the -modfile flag or has no go.mod file. + if !modfileFlagEnabled || v.realMod == "" { return nil } if modfileFlag, err := v.modfileFlagExists(ctx, v.Options().Env); err != nil { diff --git a/internal/lsp/lsp_test.go b/internal/lsp/lsp_test.go index debdae08ba..84e776db64 100644 --- a/internal/lsp/lsp_test.go +++ b/internal/lsp/lsp_test.go @@ -51,7 +51,6 @@ func testLSP(t *testing.T, exporter packagestest.Exporter) { cache := cache.New(nil) session := cache.NewSession() options := tests.DefaultOptions() - options.TempModfile = exporter == packagestest.Modules session.SetOptions(options) options.Env = datum.Config.Env v, _, err := session.NewView(ctx, datum.Config.Dir, span.FileURI(datum.Config.Dir), options) diff --git a/internal/lsp/source/options.go b/internal/lsp/source/options.go index 088e9d816f..a11513d6d4 100644 --- a/internal/lsp/source/options.go +++ b/internal/lsp/source/options.go @@ -82,7 +82,7 @@ func DefaultOptions() Options { CompletionBudget: 100 * time.Millisecond, }, ExperimentalOptions: ExperimentalOptions{ - TempModfile: false, + TempModfile: true, }, Hooks: Hooks{ ComputeEdits: myers.ComputeEdits,