mirror of
https://github.com/denoland/deno.git
synced 2025-01-08 15:19:40 -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:
parent
0f8299d011
commit
b6b25671b2
2 changed files with 38 additions and 12 deletions
|
@ -1953,11 +1953,15 @@ impl SignatureHelpItem {
|
||||||
.collect::<Vec<String>>()
|
.collect::<Vec<String>>()
|
||||||
.join(", ");
|
.join(", ");
|
||||||
let suffix_text = display_parts_to_string(&self.suffix_display_parts);
|
let suffix_text = display_parts_to_string(&self.suffix_display_parts);
|
||||||
|
let documentation = display_parts_to_string(&self.documentation);
|
||||||
lsp::SignatureInformation {
|
lsp::SignatureInformation {
|
||||||
label: format!("{}{}{}", prefix_text, params_text, suffix_text),
|
label: format!("{}{}{}", prefix_text, params_text, suffix_text),
|
||||||
documentation: Some(lsp::Documentation::String(display_parts_to_string(
|
documentation: Some(lsp::Documentation::MarkupContent(
|
||||||
&self.documentation,
|
lsp::MarkupContent {
|
||||||
))),
|
kind: lsp::MarkupKind::Markdown,
|
||||||
|
value: documentation,
|
||||||
|
},
|
||||||
|
)),
|
||||||
parameters: Some(
|
parameters: Some(
|
||||||
self
|
self
|
||||||
.parameters
|
.parameters
|
||||||
|
@ -1981,13 +1985,17 @@ pub struct SignatureHelpParameter {
|
||||||
|
|
||||||
impl SignatureHelpParameter {
|
impl SignatureHelpParameter {
|
||||||
pub fn into_parameter_information(self) -> lsp::ParameterInformation {
|
pub fn into_parameter_information(self) -> lsp::ParameterInformation {
|
||||||
|
let documentation = display_parts_to_string(&self.documentation);
|
||||||
lsp::ParameterInformation {
|
lsp::ParameterInformation {
|
||||||
label: lsp::ParameterLabel::Simple(display_parts_to_string(
|
label: lsp::ParameterLabel::Simple(display_parts_to_string(
|
||||||
&self.display_parts,
|
&self.display_parts,
|
||||||
)),
|
)),
|
||||||
documentation: Some(lsp::Documentation::String(display_parts_to_string(
|
documentation: Some(lsp::Documentation::MarkupContent(
|
||||||
&self.documentation,
|
lsp::MarkupContent {
|
||||||
))),
|
kind: lsp::MarkupKind::Markdown,
|
||||||
|
value: documentation,
|
||||||
|
},
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1931,15 +1931,24 @@ fn lsp_signature_help() {
|
||||||
"signatures": [
|
"signatures": [
|
||||||
{
|
{
|
||||||
"label": "add(a: number, b: number): number",
|
"label": "add(a: number, b: number): number",
|
||||||
"documentation": "Adds two numbers.",
|
"documentation": {
|
||||||
|
"kind": "markdown",
|
||||||
|
"value": "Adds two numbers."
|
||||||
|
},
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"label": "a: number",
|
"label": "a: number",
|
||||||
"documentation": "This is a first number."
|
"documentation": {
|
||||||
|
"kind": "markdown",
|
||||||
|
"value": "This is a first number."
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "b: 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": [
|
"signatures": [
|
||||||
{
|
{
|
||||||
"label": "add(a: number, b: number): number",
|
"label": "add(a: number, b: number): number",
|
||||||
"documentation": "Adds two numbers.",
|
"documentation": {
|
||||||
|
"kind": "markdown",
|
||||||
|
"value": "Adds two numbers."
|
||||||
|
},
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"label": "a: number",
|
"label": "a: number",
|
||||||
"documentation": "This is a first number."
|
"documentation": {
|
||||||
|
"kind": "markdown",
|
||||||
|
"value": "This is a first number."
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "b: number",
|
"label": "b: number",
|
||||||
"documentation": "This is a second number."
|
"documentation": {
|
||||||
|
"kind": "markdown",
|
||||||
|
"value": "This is a second number."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue