]> git.lizzy.rs Git - rust.git/commitdiff
Hover tooltip module name is monospace once again
authorAaron Loucks <aloucks@cofront.net>
Tue, 26 May 2020 03:18:45 +0000 (23:18 -0400)
committerAaron Loucks <aloucks@cofront.net>
Tue, 26 May 2020 03:18:45 +0000 (23:18 -0400)
The line separator is moved below the function signature to split
regions between the docs. This is very similar to how IntelliJ
displays tooltips. Adding an additional separator between the module
name and function signature currently has rendering issues.

Fixes #4594
Alternative to #4615

crates/ra_ide/src/display.rs
crates/ra_ide/src/hover.rs
crates/rust-analyzer/tests/heavy_tests/main.rs

index 8bb312156878394143b83e0b53b432e69294c4d7..827c094e7163878b4b84ce46787a06438206bb79 100644 (file)
@@ -83,12 +83,13 @@ pub(crate) fn rust_code_markup_with_doc(
 
     if let Some(mod_path) = mod_path {
         if !mod_path.is_empty() {
-            format_to!(buf, "{}\n___\n\n", mod_path);
+            format_to!(buf, "```rust\n{}\n```\n\n", mod_path);
         }
     }
     format_to!(buf, "```rust\n{}\n```", code);
 
     if let Some(doc) = doc {
+        format_to!(buf, "\n___");
         format_to!(buf, "\n\n{}", doc);
     }
 
index 1f4f6b84802143306c9e5baba88c485156423fa5..3e721dcca392b5377c95418f053cb747c1c1a5e3 100644 (file)
@@ -405,7 +405,7 @@ fn main() {
                 };
             }
         "#,
-            &["Foo\n___\n\n```rust\nfield_a: u32"],
+            &["Foo\n```\n\n```rust\nfield_a: u32"],
         );
 
         // Hovering over the field in the definition
@@ -422,7 +422,7 @@ fn main() {
                 };
             }
         "#,
-            &["Foo\n___\n\n```rust\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\n___\n\n```rust\nSome"));
+        assert_eq!(trim_markup_opt(hover.info.first()), Some("Option\n```\n\n```rust\nSome"));
 
         let (analysis, position) = single_file_with_position(
             "
@@ -503,11 +503,12 @@ enum Option<T> {
         "#,
             &["
 Option
-___
+```
 
 ```rust
 None
 ```
+___
 
 The None variant
             "
@@ -527,11 +528,12 @@ fn main() {
         "#,
             &["
 Option
-___
+```
 
 ```rust
 Some
 ```
+___
 
 The Some variant
             "
@@ -614,7 +616,7 @@ fn main() {
         let hover = analysis.hover(position).unwrap().unwrap();
         assert_eq!(
             trim_markup_opt(hover.info.first()),
-            Some("wrapper::Thing\n___\n\n```rust\nfn new() -> Thing")
+            Some("wrapper::Thing\n```\n\n```rust\nfn new() -> Thing")
         );
     }
 
@@ -891,7 +893,7 @@ fn bar() {
                 fo<|>o();
             }
             ",
-            &["fn foo()\n```\n\n<- `\u{3000}` here"],
+            &["fn foo()\n```\n___\n\n<- `\u{3000}` here"],
         );
     }
 
index b1bfc968a8dc3272e7560f8b91b6fd2764a2cd7b..405ddb362969ed3a6da61d9f1f44d86aedc02c9c 100644 (file)
@@ -756,5 +756,5 @@ pub fn foo(_input: TokenStream) -> TokenStream {
     });
 
     let value = res.get("contents").unwrap().get("value").unwrap().to_string();
-    assert_eq!(value, r#""foo::Bar\n___\n\n```rust\nfn bar()\n```""#)
+    assert_eq!(value, r#""```rust\nfoo::Bar\n```\n\n```rust\nfn bar()\n```""#)
 }