From db926218b2082077750291f8426ddd28b284cd08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Galil=C3=A9e=20=27Bill=27=20Enguehard?= Date: Thu, 21 May 2020 12:06:29 +0200 Subject: Add extra newline after module path in hover info Closes issue #3813 --- crates/ra_ide/src/display.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ra_ide/src/display.rs b/crates/ra_ide/src/display.rs index 722092de9..cb3508086 100644 --- a/crates/ra_ide/src/display.rs +++ b/crates/ra_ide/src/display.rs @@ -83,7 +83,7 @@ pub(crate) fn rust_code_markup_with_doc( if let Some(mod_path) = mod_path { if !mod_path.is_empty() { - format_to!(buf, "{}\n", mod_path); + format_to!(buf, "{}\n\n", mod_path); } } format_to!(buf, "{}\n```", code); -- cgit v1.2.3 From 5043c9ce9c9d07263305ef0e560b8ce506593748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Galil=C3=A9e=20=27Bill=27=20Enguehard?= Date: Fri, 22 May 2020 19:04:39 +0200 Subject: Modify hover info to show module path separated by a line --- crates/ra_ide/src/display.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/ra_ide/src/display.rs b/crates/ra_ide/src/display.rs index cb3508086..323505ef6 100644 --- a/crates/ra_ide/src/display.rs +++ b/crates/ra_ide/src/display.rs @@ -79,14 +79,14 @@ pub(crate) fn rust_code_markup_with_doc( doc: Option<&str>, mod_path: Option<&str>, ) -> String { - let mut buf = "```rust\n".to_owned(); + let mut buf = "".to_owned(); if let Some(mod_path) = mod_path { if !mod_path.is_empty() { - format_to!(buf, "{}\n\n", mod_path); + format_to!(buf, "{}\n___\n", mod_path); } } - format_to!(buf, "{}\n```", code); + format_to!(buf, "```rust\n\n{}\n```", code); if let Some(doc) = doc { format_to!(buf, "\n\n{}", doc); -- cgit v1.2.3 From 910ac5a21399115ab5a4e1dc423da64fd91e7e15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Galil=C3=A9e=20=27Bill=27=20Enguehard?= Date: Fri, 22 May 2020 20:10:37 +0200 Subject: Fix formatting error when no modpath is present --- crates/ra_ide/src/display.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/ra_ide/src/display.rs b/crates/ra_ide/src/display.rs index 323505ef6..8bb312156 100644 --- a/crates/ra_ide/src/display.rs +++ b/crates/ra_ide/src/display.rs @@ -79,14 +79,14 @@ pub(crate) fn rust_code_markup_with_doc( doc: Option<&str>, mod_path: Option<&str>, ) -> String { - let mut buf = "".to_owned(); + let mut buf = String::new(); if let Some(mod_path) = mod_path { if !mod_path.is_empty() { - format_to!(buf, "{}\n___\n", mod_path); + format_to!(buf, "{}\n___\n\n", mod_path); } } - format_to!(buf, "```rust\n\n{}\n```", code); + format_to!(buf, "```rust\n{}\n```", code); if let Some(doc) = doc { format_to!(buf, "\n\n{}", doc); -- cgit v1.2.3 From d688215f25b8da06b825da5942763c0faf2f7454 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Galil=C3=A9e=20=27Bill=27=20Enguehard?= Date: Fri, 22 May 2020 20:11:24 +0200 Subject: Update tests to accept new hover formatting --- crates/ra_ide/src/hover.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index befa977c7..1f4f6b848 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs @@ -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 @@ -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(); - 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( " @@ -503,6 +503,9 @@ fn main() { "#, &[" Option +___ + +```rust None ``` @@ -524,6 +527,9 @@ The None variant "#, &[" Option +___ + +```rust Some ``` @@ -606,7 +612,10 @@ fn func(foo: i32) { if true { <|>foo; }; } ", ); 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] -- cgit v1.2.3 From 6197a960dffa4c7e8c2f60168a476e5f39ba50aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Galil=C3=A9e=20=27Bill=27=20Enguehard?= Date: Sat, 23 May 2020 08:59:51 +0200 Subject: Fix resolve_proc_macro heavy test --- crates/rust-analyzer/tests/heavy_tests/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/rust-analyzer/tests/heavy_tests/main.rs b/crates/rust-analyzer/tests/heavy_tests/main.rs index 4e94c37e1..738a9a8e3 100644 --- a/crates/rust-analyzer/tests/heavy_tests/main.rs +++ b/crates/rust-analyzer/tests/heavy_tests/main.rs @@ -774,5 +774,5 @@ pub fn foo(_input: TokenStream) -> TokenStream { }); 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```""#) } -- cgit v1.2.3