@@ -51,6 +51,55 @@ var FooErr = errors.New("foo")
51
51
})
52
52
}
53
53
54
+ // TestMajorOptionsChange is like TestChangeConfiguration, but modifies an
55
+ // an open buffer before making a major (but inconsequential) change that
56
+ // causes gopls to recreate the view.
57
+ //
58
+ // Gopls should not get confused about buffer content when recreating the view.
59
+ func TestMajorOptionsChange (t * testing.T ) {
60
+ t .Skip ("broken due to golang/go#57934" )
61
+
62
+ testenv .NeedsGo1Point (t , 17 )
63
+
64
+ const files = `
65
+ -- go.mod --
66
+ module mod.com
67
+
68
+ go 1.12
69
+ -- a/a.go --
70
+ package a
71
+
72
+ import "errors"
73
+
74
+ var ErrFoo = errors.New("foo")
75
+ `
76
+ Run (t , files , func (t * testing.T , env * Env ) {
77
+ env .OpenFile ("a/a.go" )
78
+ // Introduce a staticcheck diagnostic. It should be detected when we enable
79
+ // staticcheck later.
80
+ env .RegexpReplace ("a/a.go" , "ErrFoo" , "FooErr" )
81
+ env .AfterChange (
82
+ NoDiagnostics (ForFile ("a/a.go" )),
83
+ )
84
+ cfg := env .Editor .Config ()
85
+ // Any change to environment recreates the view, but this should not cause
86
+ // gopls to get confused about the content of a/a.go: we should get the
87
+ // staticcheck diagnostic below.
88
+ cfg .Env = map [string ]string {
89
+ "AN_ARBITRARY_VAR" : "FOO" ,
90
+ }
91
+ cfg .Settings = map [string ]interface {}{
92
+ "staticcheck" : true ,
93
+ }
94
+ // TODO(rfindley): support waiting on diagnostics following a configuration
95
+ // change.
96
+ env .ChangeConfiguration (cfg )
97
+ env .Await (
98
+ Diagnostics (env .AtRegexp ("a/a.go" , "var (FooErr)" )),
99
+ )
100
+ })
101
+ }
102
+
54
103
func TestStaticcheckWarning (t * testing.T ) {
55
104
// Note: keep this in sync with TestChangeConfiguration.
56
105
testenv .SkipAfterGo1Point (t , 16 )
0 commit comments