mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
Merge #4559
4559: Module name on hover shows another newline after it r=matklad a=Arthamys This changes the display of hover information to add a newline between the module path of the item and the signature of the item, as suggested in #3813 **Before**  **After**  Co-authored-by: Galilée 'Bill' Enguehard <galilee.enguehard@gmail.com>
This commit is contained in:
commit
88c292b1c2
@ -79,14 +79,14 @@ pub(crate) fn rust_code_markup_with_doc(
|
|||||||
doc: Option<&str>,
|
doc: Option<&str>,
|
||||||
mod_path: Option<&str>,
|
mod_path: Option<&str>,
|
||||||
) -> String {
|
) -> String {
|
||||||
let mut buf = "```rust\n".to_owned();
|
let mut buf = String::new();
|
||||||
|
|
||||||
if let Some(mod_path) = mod_path {
|
if let Some(mod_path) = mod_path {
|
||||||
if !mod_path.is_empty() {
|
if !mod_path.is_empty() {
|
||||||
format_to!(buf, "{}\n", mod_path);
|
format_to!(buf, "{}\n___\n\n", mod_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
format_to!(buf, "{}\n```", code);
|
format_to!(buf, "```rust\n{}\n```", code);
|
||||||
|
|
||||||
if let Some(doc) = doc {
|
if let Some(doc) = doc {
|
||||||
format_to!(buf, "\n\n{}", doc);
|
format_to!(buf, "\n\n{}", doc);
|
||||||
|
@ -405,7 +405,7 @@ mod tests {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
&["Foo\nfield_a: u32"],
|
&["Foo\n___\n\n```rust\nfield_a: u32"],
|
||||||
);
|
);
|
||||||
|
|
||||||
// Hovering over the field in the definition
|
// Hovering over the field in the definition
|
||||||
@ -422,7 +422,7 @@ mod tests {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
"#,
|
"#,
|
||||||
&["Foo\nfield_a: u32"],
|
&["Foo\n___\n\n```rust\nfield_a: u32"],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -475,7 +475,7 @@ fn main() {
|
|||||||
",
|
",
|
||||||
);
|
);
|
||||||
let hover = analysis.hover(position).unwrap().unwrap();
|
let hover = analysis.hover(position).unwrap().unwrap();
|
||||||
assert_eq!(trim_markup_opt(hover.info.first()), Some("Option\nSome"));
|
assert_eq!(trim_markup_opt(hover.info.first()), Some("Option\n___\n\n```rust\nSome"));
|
||||||
|
|
||||||
let (analysis, position) = single_file_with_position(
|
let (analysis, position) = single_file_with_position(
|
||||||
"
|
"
|
||||||
@ -503,6 +503,9 @@ fn main() {
|
|||||||
"#,
|
"#,
|
||||||
&["
|
&["
|
||||||
Option
|
Option
|
||||||
|
___
|
||||||
|
|
||||||
|
```rust
|
||||||
None
|
None
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -524,6 +527,9 @@ The None variant
|
|||||||
"#,
|
"#,
|
||||||
&["
|
&["
|
||||||
Option
|
Option
|
||||||
|
___
|
||||||
|
|
||||||
|
```rust
|
||||||
Some
|
Some
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -606,7 +612,10 @@ fn func(foo: i32) { if true { <|>foo; }; }
|
|||||||
",
|
",
|
||||||
);
|
);
|
||||||
let hover = analysis.hover(position).unwrap().unwrap();
|
let hover = analysis.hover(position).unwrap().unwrap();
|
||||||
assert_eq!(trim_markup_opt(hover.info.first()), Some("wrapper::Thing\nfn new() -> Thing"));
|
assert_eq!(
|
||||||
|
trim_markup_opt(hover.info.first()),
|
||||||
|
Some("wrapper::Thing\n___\n\n```rust\nfn new() -> Thing")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -774,5 +774,5 @@ pub fn foo(_input: TokenStream) -> TokenStream {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let value = res.get("contents").unwrap().get("value").unwrap().to_string();
|
let value = res.get("contents").unwrap().get("value").unwrap().to_string();
|
||||||
assert_eq!(value, r#""```rust\nfoo::Bar\nfn bar()\n```""#)
|
assert_eq!(value, r#""foo::Bar\n___\n\n```rust\nfn bar()\n```""#)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user