Skip to content

Commit

Permalink
Re-parse experimental client capability for textDocumentContent
Browse files Browse the repository at this point in the history
  • Loading branch information
fwcd committed Sep 4, 2024
1 parent dd7669a commit 99836e0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Sources/SourceKitLSP/SourceKitLSPServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,8 @@ extension SourceKitLSPServer {
//
// The below is a workaround for the vscode-swift extension since it cannot set client capabilities.
// It passes "workspace/peekDocuments" through the `initializationOptions`.
//
// Similarly for "workspace/textDocumentContent".
var clientCapabilities = req.capabilities
if case .dictionary(let initializationOptions) = req.initializationOptions {
if let peekDocuments = initializationOptions["workspace/peekDocuments"] {
Expand All @@ -997,6 +999,15 @@ extension SourceKitLSPServer {
}
}

if let textDocumentContent = initializationOptions["workspace/textDocumentContent"] {
if case .dictionary(var experimentalCapabilities) = clientCapabilities.experimental {
experimentalCapabilities["workspace/textDocumentContent"] = textDocumentContent
clientCapabilities.experimental = .dictionary(experimentalCapabilities)
} else {
clientCapabilities.experimental = .dictionary(["workspace/textDocumentContent": textDocumentContent])
}
}

// The client announces what CodeLenses it supports, and the LSP will only return
// ones found in the supportedCommands dictionary.
if let codeLens = initializationOptions["textDocument/codeLens"],
Expand Down

0 comments on commit 99836e0

Please sign in to comment.