diff --git a/internal/lsp/lsp_test.go b/internal/lsp/lsp_test.go index 34d8316f74..3bb180fdfc 100644 --- a/internal/lsp/lsp_test.go +++ b/internal/lsp/lsp_test.go @@ -182,10 +182,9 @@ func (r *runner) Diagnostics(t *testing.T, uri span.URI, want []*source.Diagnost // Get the diagnostics for this view if we have not done it before. v := r.server.session.View(r.data.Config.Dir) r.collectDiagnostics(v) - var got []*source.Diagnostic - for _, d := range r.diagnostics[uri] { - got = append(got, d) - } + d := r.diagnostics[uri] + got := make([]*source.Diagnostic, len(d)) + copy(got, d) // A special case to test that there are no diagnostics for a file. if len(want) == 1 && want[0].Source == "no_diagnostics" { if len(got) != 0 { diff --git a/internal/lsp/source/options.go b/internal/lsp/source/options.go index 0ce5fb7237..c1084afb53 100644 --- a/internal/lsp/source/options.go +++ b/internal/lsp/source/options.go @@ -510,8 +510,8 @@ func (o *Options) Clone() *Options { return result } -func (options *Options) AddStaticcheckAnalyzer(a *analysis.Analyzer) { - options.StaticcheckAnalyzers[a.Name] = Analyzer{Analyzer: a, Enabled: true} +func (o *Options) AddStaticcheckAnalyzer(a *analysis.Analyzer) { + o.StaticcheckAnalyzers[a.Name] = Analyzer{Analyzer: a, Enabled: true} } func (o *Options) set(name string, value interface{}) OptionResult {