Skip to content

Commit

Permalink
internal/lsp: handle the didChangeConfiguration message
Browse files Browse the repository at this point in the history
It uses it to update the config of all active views cleanly
Fixes golang/go#32258

Change-Id: I7a849941d5022499d48ad640c5b7bc9cf79eb9b9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/206148
Run-TryBot: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
  • Loading branch information
ianthehat committed Nov 12, 2019
1 parent c41a8f5 commit 74addff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/lsp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ func (s *Server) DidChangeWorkspaceFolders(ctx context.Context, params *protocol
return s.changeFolders(ctx, params.Event)
}

func (s *Server) DidChangeConfiguration(context.Context, *protocol.DidChangeConfigurationParams) error {
return notImplemented("DidChangeConfiguration")
func (s *Server) DidChangeConfiguration(ctx context.Context, params *protocol.DidChangeConfigurationParams) error {
return s.updateConfiguration(ctx, params.Settings)
}

func (s *Server) DidChangeWatchedFiles(ctx context.Context, params *protocol.DidChangeWatchedFilesParams) error {
Expand Down
9 changes: 9 additions & 0 deletions internal/lsp/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,14 @@ func (s *Server) addView(ctx context.Context, name string, uri span.URI) (source
s.fetchConfig(ctx, name, uri, &options)

return s.session.NewView(ctx, name, uri, options)
}

func (s *Server) updateConfiguration(ctx context.Context, changed interface{}) error {
// go through all the views getting the config
for _, view := range s.session.Views() {
options := s.session.Options()
s.fetchConfig(ctx, view.Name(), view.Folder(), &options)
view.SetOptions(ctx, options)
}
return nil
}

0 comments on commit 74addff

Please sign in to comment.