@@ -9,11 +9,13 @@ import (
9
9
"fmt"
10
10
"io/ioutil"
11
11
"path/filepath"
12
+ "sort"
12
13
"strings"
13
14
"testing"
14
15
15
16
"golang.org/x/tools/gopls/internal/hooks"
16
17
. "golang.org/x/tools/internal/lsp/regtest"
18
+ "golang.org/x/tools/internal/lsp/source"
17
19
18
20
"golang.org/x/tools/internal/lsp/command"
19
21
"golang.org/x/tools/internal/lsp/fake"
@@ -137,6 +139,38 @@ func TestReferences(t *testing.T) {
137
139
}
138
140
}
139
141
142
+ // make sure that directory filters work
143
+ func TestFilters (t * testing.T ) {
144
+ for _ , tt := range []struct {
145
+ name , rootPath string
146
+ }{
147
+ {
148
+ name : "module root" ,
149
+ rootPath : "pkg" ,
150
+ },
151
+ } {
152
+ t .Run (tt .name , func (t * testing.T ) {
153
+ opts := []RunOption {ProxyFiles (workspaceProxy )}
154
+ if tt .rootPath != "" {
155
+ opts = append (opts , WorkspaceFolders (tt .rootPath ))
156
+ }
157
+ f := func (o * source.Options ) {
158
+ o .DirectoryFilters = append (o .DirectoryFilters , "-inner" )
159
+ }
160
+ opts = append (opts , Options (f ))
161
+ WithOptions (opts ... ).Run (t , workspaceModule , func (t * testing.T , env * Env ) {
162
+ syms := env .WorkspaceSymbol ("Hi" )
163
+ sort .Slice (syms , func (i , j int ) bool { return syms [i ].ContainerName < syms [j ].ContainerName })
164
+ for i , s := range syms {
165
+ if strings .Contains (s .ContainerName , "/inner" ) {
166
+ t .Errorf ("%s %v %s %s %d\n " , s .Name , s .Kind , s .ContainerName , tt .name , i )
167
+ }
168
+ }
169
+ })
170
+ })
171
+ }
172
+ }
173
+
140
174
// Make sure that analysis diagnostics are cleared for the whole package when
141
175
// the only opened file is closed. This test was inspired by the experience in
142
176
// VS Code, where clicking on a reference result triggers a
0 commit comments