fix(lsp): display signature docs as markdown (#12636)

These were previously displayed as plain text. Now they are displayed as
`MarkupContent` with type `Markdown`.
This commit is contained in:
Luca Casonato 2021-11-07 23:26:11 +01:00 committed by GitHub
parent 0f8299d011
commit b6b25671b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 12 deletions

View file

@ -1953,11 +1953,15 @@ impl SignatureHelpItem {
.collect::<Vec<String>>()
.join(", ");
let suffix_text = display_parts_to_string(&self.suffix_display_parts);
let documentation = display_parts_to_string(&self.documentation);
lsp::SignatureInformation {
label: format!("{}{}{}", prefix_text, params_text, suffix_text),
documentation: Some(lsp::Documentation::String(display_parts_to_string(
&self.documentation,
))),
documentation: Some(lsp::Documentation::MarkupContent(
lsp::MarkupContent {
kind: lsp::MarkupKind::Markdown,
value: documentation,
},
)),
parameters: Some(
self
.parameters
@ -1981,13 +1985,17 @@ pub struct SignatureHelpParameter {
impl SignatureHelpParameter {
pub fn into_parameter_information(self) -> lsp::ParameterInformation {
let documentation = display_parts_to_string(&self.documentation);
lsp::ParameterInformation {
label: lsp::ParameterLabel::Simple(display_parts_to_string(
&self.display_parts,
)),
documentation: Some(lsp::Documentation::String(display_parts_to_string(
&self.documentation,
))),
documentation: Some(lsp::Documentation::MarkupContent(
lsp::MarkupContent {
kind: lsp::MarkupKind::Markdown,
value: documentation,
},
)),
}
}
}