Skip to content

Commit

Permalink
internal/lsp/source: small fixes to directory filters
Browse files Browse the repository at this point in the history
Add missing newlines in documentation, and allow trailing slashes in the
filter expressions.

Change-Id: I90106b209222d8cc542e3517c6ff6edb2569243d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/308453
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
  • Loading branch information
heschi committed Apr 8, 2021
1 parent b261fe9 commit be791d0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions gopls/doc/settings.md
Expand Up @@ -63,8 +63,11 @@ the last filter that applies to a path controls whether it is included.
The path prefix can be empty, so an initial `-` excludes everything.

Examples:

Exclude node_modules: `-node_modules`

Include only project_a: `-` (exclude everything), `+project_a`

Include only project_a, but not node_modules inside it: `-`, `+project_a`, `-project_a/node_modules`

Default: `[]`.
Expand Down
2 changes: 1 addition & 1 deletion internal/lsp/source/api_json.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion internal/lsp/source/options.go
Expand Up @@ -213,8 +213,11 @@ type BuildOptions struct {
// The path prefix can be empty, so an initial `-` excludes everything.
//
// Examples:
//
// Exclude node_modules: `-node_modules`
//
// Include only project_a: `-` (exclude everything), `+project_a`
//
// Include only project_a, but not node_modules inside it: `-`, `+project_a`, `-project_a/node_modules`
DirectoryFilters []string

Expand Down Expand Up @@ -747,7 +750,7 @@ func (o *Options) set(name string, value interface{}, seen map[string]struct{})
result.errorf("invalid filter %q, must start with + or -", filter)
return result
}
filters = append(filters, filepath.FromSlash(filter))
filters = append(filters, strings.TrimRight(filepath.FromSlash(filter), "/"))
}
o.DirectoryFilters = filters
case "completionDocumentation":
Expand Down

0 comments on commit be791d0

Please sign in to comment.