File tree 2 files changed +38
-2
lines changed
src/tools/rust-analyzer/crates/ide/src/hover 2 files changed +38
-2
lines changed Original file line number Diff line number Diff line change @@ -716,16 +716,21 @@ pub(super) fn literal(
716
716
match value {
717
717
Ok ( value) => {
718
718
let backtick_len = value. chars ( ) . filter ( |c| * c == '`' ) . count ( ) ;
719
+ let spaces_len = value. chars ( ) . filter ( |c| * c == ' ' ) . count ( ) ;
719
720
let backticks = "`" . repeat ( backtick_len + 1 ) ;
721
+ let space_char = if spaces_len == value. len ( ) { "" } else { " " } ;
720
722
721
723
if let Some ( newline) = value. find ( '\n' ) {
722
724
format_to ! (
723
725
s,
724
- "value of literal (truncated up to newline): {backticks} {} {backticks}" ,
726
+ "value of literal (truncated up to newline): {backticks}{space_char}{}{space_char} {backticks}" ,
725
727
& value[ ..newline]
726
728
)
727
729
} else {
728
- format_to ! ( s, "value of literal: {backticks} {value} {backticks}" )
730
+ format_to ! (
731
+ s,
732
+ "value of literal: {backticks}{space_char}{value}{space_char}{backticks}"
733
+ )
729
734
}
730
735
}
731
736
Err ( error) => format_to ! ( s, "invalid literal: {error}" ) ,
Original file line number Diff line number Diff line change @@ -8303,6 +8303,37 @@ fn main() {
8303
8303
value of literal: `` ` ``
8304
8304
"# ] ] ,
8305
8305
) ;
8306
+ check (
8307
+ r#"
8308
+ fn main() {
8309
+ $0r" ";
8310
+ }"# ,
8311
+ expect ! [ [ r#"
8312
+ *r" "*
8313
+ ```rust
8314
+ &str
8315
+ ```
8316
+ ___
8317
+
8318
+ value of literal: ` `
8319
+ "# ] ] ,
8320
+ ) ;
8321
+ check (
8322
+ r#"
8323
+ fn main() {
8324
+ $0r" Hello World ";
8325
+
8326
+ }"# ,
8327
+ expect ! [ [ r#"
8328
+ *r" Hello World "*
8329
+ ```rust
8330
+ &str
8331
+ ```
8332
+ ___
8333
+
8334
+ value of literal: ` Hello World `
8335
+ "# ] ] ,
8336
+ )
8306
8337
}
8307
8338
8308
8339
#[ test]
You can’t perform that action at this time.
0 commit comments