From 3f2bc813d3b91fbf8a0007eb11c192061571873b Mon Sep 17 00:00:00 2001 From: JmPotato Date: Sun, 9 Aug 2020 21:33:14 +0800 Subject: format in to_proto::markup_content Signed-off-by: JmPotato --- crates/ra_ide/src/hover.rs | 31 +++++++++++++++++++++++++++++++ crates/rust-analyzer/src/to_proto.rs | 3 ++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index aa48cb412..385e3e64e 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs @@ -508,6 +508,37 @@ fn main() { } ); } + #[test] + fn hover_shows_fn_doc() { + check( + r#" +/// # Example +/// ``` +/// # use std::path::Path; +/// # +/// foo(Path::new("hello, world!")) +/// ``` +pub fn foo<|>(_: &Path) {} + +fn main() { } +"#, + expect![[r#" + *foo* + ```rust + pub fn foo(_: &Path) + ``` + ___ + + # Example + ``` + # use std::path::Path; + # + foo(Path::new("hello, world!")) + ``` + "#]], + ); + } + #[test] fn hover_shows_struct_field_info() { // Hovering over the field when instantiating diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 5eba1f155..27460db78 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs @@ -755,7 +755,8 @@ pub(crate) fn runnable( } pub(crate) fn markup_content(markup: Markup) -> lsp_types::MarkupContent { - lsp_types::MarkupContent { kind: lsp_types::MarkupKind::Markdown, value: markup.into() } + let value = crate::markdown::format_docs(markup.as_str()); + lsp_types::MarkupContent { kind: lsp_types::MarkupKind::Markdown, value } } #[cfg(test)] -- cgit v1.2.3