1
0
mirror of https://github.com/golang/go synced 2024-09-30 22:58:34 -06:00

internal/lsp: handle the didChangeConfiguration message

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>
This commit is contained in:
Ian Cottrell 2019-11-08 13:26:32 -05:00
parent c41a8f58b5
commit 74addff584
2 changed files with 12 additions and 3 deletions

View File

@ -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 {

View File

@ -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
}