Skip to content

Commit 88c292b

Browse files
bors[bot]Arthamys
andauthored
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** ![before_3813](https://user-images.githubusercontent.com/11710698/82609224-5d517d80-9bbc-11ea-9a08-0a1558409c6b.png) **After** ![after_3813](https://user-images.githubusercontent.com/11710698/82609208-562a6f80-9bbc-11ea-8cb6-4430269c5800.png) Co-authored-by: Galilée 'Bill' Enguehard <[email protected]>
2 parents d4daca9 + 6197a96 commit 88c292b

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

crates/ra_ide/src/display.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ pub(crate) fn rust_code_markup_with_doc(
7979
doc: Option<&str>,
8080
mod_path: Option<&str>,
8181
) -> String {
82-
let mut buf = "```rust\n".to_owned();
82+
let mut buf = String::new();
8383

8484
if let Some(mod_path) = mod_path {
8585
if !mod_path.is_empty() {
86-
format_to!(buf, "{}\n", mod_path);
86+
format_to!(buf, "{}\n___\n\n", mod_path);
8787
}
8888
}
89-
format_to!(buf, "{}\n```", code);
89+
format_to!(buf, "```rust\n{}\n```", code);
9090

9191
if let Some(doc) = doc {
9292
format_to!(buf, "\n\n{}", doc);

crates/ra_ide/src/hover.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ mod tests {
405405
};
406406
}
407407
"#,
408-
&["Foo\nfield_a: u32"],
408+
&["Foo\n___\n\n```rust\nfield_a: u32"],
409409
);
410410

411411
// Hovering over the field in the definition
@@ -422,7 +422,7 @@ mod tests {
422422
};
423423
}
424424
"#,
425-
&["Foo\nfield_a: u32"],
425+
&["Foo\n___\n\n```rust\nfield_a: u32"],
426426
);
427427
}
428428

@@ -475,7 +475,7 @@ fn main() {
475475
",
476476
);
477477
let hover = analysis.hover(position).unwrap().unwrap();
478-
assert_eq!(trim_markup_opt(hover.info.first()), Some("Option\nSome"));
478+
assert_eq!(trim_markup_opt(hover.info.first()), Some("Option\n___\n\n```rust\nSome"));
479479

480480
let (analysis, position) = single_file_with_position(
481481
"
@@ -503,6 +503,9 @@ fn main() {
503503
"#,
504504
&["
505505
Option
506+
___
507+
508+
```rust
506509
None
507510
```
508511
@@ -524,6 +527,9 @@ The None variant
524527
"#,
525528
&["
526529
Option
530+
___
531+
532+
```rust
527533
Some
528534
```
529535
@@ -606,7 +612,10 @@ fn func(foo: i32) { if true { <|>foo; }; }
606612
",
607613
);
608614
let hover = analysis.hover(position).unwrap().unwrap();
609-
assert_eq!(trim_markup_opt(hover.info.first()), Some("wrapper::Thing\nfn new() -> Thing"));
615+
assert_eq!(
616+
trim_markup_opt(hover.info.first()),
617+
Some("wrapper::Thing\n___\n\n```rust\nfn new() -> Thing")
618+
);
610619
}
611620

612621
#[test]

crates/rust-analyzer/tests/heavy_tests/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,5 +774,5 @@ pub fn foo(_input: TokenStream) -> TokenStream {
774774
});
775775

776776
let value = res.get("contents").unwrap().get("value").unwrap().to_string();
777-
assert_eq!(value, r#""```rust\nfoo::Bar\nfn bar()\n```""#)
777+
assert_eq!(value, r#""foo::Bar\n___\n\n```rust\nfn bar()\n```""#)
778778
}

0 commit comments

Comments
 (0)