1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 15:24:46 -05:00

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,
},
)),
}
}
}

View file

@ -1931,15 +1931,24 @@ fn lsp_signature_help() {
"signatures": [
{
"label": "add(a: number, b: number): number",
"documentation": "Adds two numbers.",
"documentation": {
"kind": "markdown",
"value": "Adds two numbers."
},
"parameters": [
{
"label": "a: number",
"documentation": "This is a first number."
"documentation": {
"kind": "markdown",
"value": "This is a first number."
}
},
{
"label": "b: number",
"documentation": "This is a second number."
"documentation": {
"kind": "markdown",
"value": "This is a second number."
}
}
]
}
@ -1995,15 +2004,24 @@ fn lsp_signature_help() {
"signatures": [
{
"label": "add(a: number, b: number): number",
"documentation": "Adds two numbers.",
"documentation": {
"kind": "markdown",
"value": "Adds two numbers."
},
"parameters": [
{
"label": "a: number",
"documentation": "This is a first number."
"documentation": {
"kind": "markdown",
"value": "This is a first number."
}
},
{
"label": "b: number",
"documentation": "This is a second number."
"documentation": {
"kind": "markdown",
"value": "This is a second number."
}
}
]
}