aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-08-09 19:02:02 +0100
committerGitHub <[email protected]>2020-08-09 19:02:02 +0100
commit859963b9a712817a486088997b23583467cf4958 (patch)
treeda6482eef637293beff5dd010134bf06b24c4360 /crates
parent8a57afe5a4bfab40072a83f7dc4ca560bf860919 (diff)
parent3f2bc813d3b91fbf8a0007eb11c192061571873b (diff)
Merge #5694
5694: Format docs in to_proto::markup_content r=jonas-schievink a=JmPotato Signed-off-by: JmPotato <[email protected]> Close #5442 Removing # was handled in rust_analyzer::markdown::format_docs(). However, this function is no longer called in rust_analyzer::handlers::handle_hover() since commit e8bb153 (PR #5273). This pr add this formatting function back. Co-authored-by: JmPotato <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_ide/src/hover.rs31
-rw-r--r--crates/rust-analyzer/src/to_proto.rs3
2 files changed, 33 insertions, 1 deletions
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
@@ -509,6 +509,37 @@ fn main() { }
509 } 509 }
510 510
511 #[test] 511 #[test]
512 fn hover_shows_fn_doc() {
513 check(
514 r#"
515/// # Example
516/// ```
517/// # use std::path::Path;
518/// #
519/// foo(Path::new("hello, world!"))
520/// ```
521pub fn foo<|>(_: &Path) {}
522
523fn main() { }
524"#,
525 expect![[r#"
526 *foo*
527 ```rust
528 pub fn foo(_: &Path)
529 ```
530 ___
531
532 # Example
533 ```
534 # use std::path::Path;
535 #
536 foo(Path::new("hello, world!"))
537 ```
538 "#]],
539 );
540 }
541
542 #[test]
512 fn hover_shows_struct_field_info() { 543 fn hover_shows_struct_field_info() {
513 // Hovering over the field when instantiating 544 // Hovering over the field when instantiating
514 check( 545 check(
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(
755} 755}
756 756
757pub(crate) fn markup_content(markup: Markup) -> lsp_types::MarkupContent { 757pub(crate) fn markup_content(markup: Markup) -> lsp_types::MarkupContent {
758 lsp_types::MarkupContent { kind: lsp_types::MarkupKind::Markdown, value: markup.into() } 758 let value = crate::markdown::format_docs(markup.as_str());
759 lsp_types::MarkupContent { kind: lsp_types::MarkupKind::Markdown, value }
759} 760}
760 761
761#[cfg(test)] 762#[cfg(test)]