Skip to content

Commit 859963b

Browse files
bors[bot]JmPotato
andauthored
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]>
2 parents 8a57afe + 3f2bc81 commit 859963b

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

crates/ra_ide/src/hover.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,37 @@ fn main() { }
508508
);
509509
}
510510

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+
/// ```
521+
pub fn foo<|>(_: &Path) {}
522+
523+
fn 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+
511542
#[test]
512543
fn hover_shows_struct_field_info() {
513544
// Hovering over the field when instantiating

crates/rust-analyzer/src/to_proto.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,8 @@ pub(crate) fn runnable(
755755
}
756756

757757
pub(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 }
759760
}
760761

761762
#[cfg(test)]

0 commit comments

Comments
 (0)