Skip to content

Commit 24389d4

Browse files
committed
internal/lsp: use the correct dynamic registration booleans
I mistakenly used DynamicConfigurationSupported for all capabilities, not just the workspace/configuration one. Fixes golang/go#48600 Change-Id: Ie9b205d89da6e4d110a5310b31fc1ba22f2b5383 Reviewed-on: https://go-review.googlesource.com/c/tools/+/352055 Trust: Rebecca Stambler <[email protected]> Run-TryBot: Rebecca Stambler <[email protected]> gopls-CI: kokoro <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Robert Findley <[email protected]>
1 parent 074820e commit 24389d4

File tree

2 files changed

+32
-32
lines changed

2 files changed

+32
-32
lines changed

internal/lsp/general.go

+10-13
Original file line numberDiff line numberDiff line change
@@ -188,20 +188,17 @@ func (s *Server) initialized(ctx context.Context, params *protocol.InitializedPa
188188
}
189189
s.pendingFolders = nil
190190

191+
var registrations []protocol.Registration
191192
if options.ConfigurationSupported && options.DynamicConfigurationSupported {
192-
registrations := []protocol.Registration{
193-
{
194-
ID: "workspace/didChangeConfiguration",
195-
Method: "workspace/didChangeConfiguration",
196-
},
197-
{
198-
ID: "workspace/didChangeWorkspaceFolders",
199-
Method: "workspace/didChangeWorkspaceFolders",
200-
},
201-
}
202-
if options.SemanticTokens {
203-
registrations = append(registrations, semanticTokenRegistration(options.SemanticTypes, options.SemanticMods))
204-
}
193+
registrations = append(registrations, protocol.Registration{
194+
ID: "workspace/didChangeConfiguration",
195+
Method: "workspace/didChangeConfiguration",
196+
})
197+
}
198+
if options.SemanticTokens && options.DynamicRegistrationSemanticTokensSupported {
199+
registrations = append(registrations, semanticTokenRegistration(options.SemanticTypes, options.SemanticMods))
200+
}
201+
if len(registrations) > 0 {
205202
if err := s.client.RegisterCapability(ctx, &protocol.RegistrationParams{
206203
Registrations: registrations,
207204
}); err != nil {

internal/lsp/source/options.go

+22-19
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,14 @@ func DefaultOptions() *Options {
8181
}
8282
defaultOptions = &Options{
8383
ClientOptions: ClientOptions{
84-
InsertTextFormat: protocol.PlainTextTextFormat,
85-
PreferredContentFormat: protocol.Markdown,
86-
ConfigurationSupported: true,
87-
DynamicConfigurationSupported: true,
88-
DynamicWatchedFilesSupported: true,
89-
LineFoldingOnly: false,
90-
HierarchicalDocumentSymbolSupport: true,
84+
InsertTextFormat: protocol.PlainTextTextFormat,
85+
PreferredContentFormat: protocol.Markdown,
86+
ConfigurationSupported: true,
87+
DynamicConfigurationSupported: true,
88+
DynamicRegistrationSemanticTokensSupported: true,
89+
DynamicWatchedFilesSupported: true,
90+
LineFoldingOnly: false,
91+
HierarchicalDocumentSymbolSupport: true,
9192
},
9293
ServerOptions: ServerOptions{
9394
SupportedCodeActions: map[FileKind]map[protocol.CodeActionKind]bool{
@@ -183,18 +184,19 @@ type Options struct {
183184
// ClientOptions holds LSP-specific configuration that is provided by the
184185
// client.
185186
type ClientOptions struct {
186-
InsertTextFormat protocol.InsertTextFormat
187-
ConfigurationSupported bool
188-
DynamicConfigurationSupported bool
189-
DynamicWatchedFilesSupported bool
190-
PreferredContentFormat protocol.MarkupKind
191-
LineFoldingOnly bool
192-
HierarchicalDocumentSymbolSupport bool
193-
SemanticTypes []string
194-
SemanticMods []string
195-
RelatedInformationSupported bool
196-
CompletionTags bool
197-
CompletionDeprecated bool
187+
InsertTextFormat protocol.InsertTextFormat
188+
ConfigurationSupported bool
189+
DynamicConfigurationSupported bool
190+
DynamicRegistrationSemanticTokensSupported bool
191+
DynamicWatchedFilesSupported bool
192+
PreferredContentFormat protocol.MarkupKind
193+
LineFoldingOnly bool
194+
HierarchicalDocumentSymbolSupport bool
195+
SemanticTypes []string
196+
SemanticMods []string
197+
RelatedInformationSupported bool
198+
CompletionTags bool
199+
CompletionDeprecated bool
198200
}
199201

200202
// ServerOptions holds LSP-specific configuration that is provided by the
@@ -655,6 +657,7 @@ func (o *Options) ForClientCapabilities(caps protocol.ClientCapabilities) {
655657
// Check if the client supports configuration messages.
656658
o.ConfigurationSupported = caps.Workspace.Configuration
657659
o.DynamicConfigurationSupported = caps.Workspace.DidChangeConfiguration.DynamicRegistration
660+
o.DynamicRegistrationSemanticTokensSupported = caps.TextDocument.SemanticTokens.DynamicRegistration
658661
o.DynamicWatchedFilesSupported = caps.Workspace.DidChangeWatchedFiles.DynamicRegistration
659662

660663
// Check which types of content format are supported by this client.

0 commit comments

Comments
 (0)