@@ -129,6 +129,11 @@ impl fmt::Debug for InlayHintLabel {
129
129
130
130
pub struct InlayHintLabelPart {
131
131
pub text : String ,
132
+ /// Source location represented by this label part. The client will use this to fetch the part's
133
+ /// hover tooltip, and Ctrl+Clicking the label part will navigate to the definition the location
134
+ /// refers to (not necessarily the location itself).
135
+ /// When setting this, no tooltip must be set on the containing hint, or VS Code will display
136
+ /// them both.
132
137
pub linked_location : Option < FileRange > ,
133
138
}
134
139
@@ -266,10 +271,10 @@ fn closing_brace_hints(
266
271
) -> Option < ( ) > {
267
272
let min_lines = config. closing_brace_hints_min_lines ?;
268
273
269
- let name = |it : ast:: Name | it. syntax ( ) . text_range ( ) . start ( ) ;
274
+ let name = |it : ast:: Name | it. syntax ( ) . text_range ( ) ;
270
275
271
276
let mut closing_token;
272
- let ( label, name_offset ) = if let Some ( item_list) = ast:: AssocItemList :: cast ( node. clone ( ) ) {
277
+ let ( label, name_range ) = if let Some ( item_list) = ast:: AssocItemList :: cast ( node. clone ( ) ) {
273
278
closing_token = item_list. r_curly_token ( ) ?;
274
279
275
280
let parent = item_list. syntax ( ) . parent ( ) ?;
@@ -279,11 +284,11 @@ fn closing_brace_hints(
279
284
let imp = sema. to_def( & imp) ?;
280
285
let ty = imp. self_ty( sema. db) ;
281
286
let trait_ = imp. trait_( sema. db) ;
282
-
283
- ( match trait_ {
287
+ let hint_text = match trait_ {
284
288
Some ( tr) => format!( "impl {} for {}" , tr. name( sema. db) , ty. display_truncated( sema. db, config. max_length) ) ,
285
289
None => format!( "impl {}" , ty. display_truncated( sema. db, config. max_length) ) ,
286
- } , None )
290
+ } ;
291
+ ( hint_text, None )
287
292
} ,
288
293
ast:: Trait ( tr) => {
289
294
( format!( "trait {}" , tr. name( ) ?) , tr. name( ) . map( name) )
@@ -327,7 +332,7 @@ fn closing_brace_hints(
327
332
328
333
(
329
334
format ! ( "{}!" , mac. path( ) ?) ,
330
- mac. path ( ) . and_then ( |it| it. segment ( ) ) . map ( |it| it. syntax ( ) . text_range ( ) . start ( ) ) ,
335
+ mac. path ( ) . and_then ( |it| it. segment ( ) ) . map ( |it| it. syntax ( ) . text_range ( ) ) ,
331
336
)
332
337
} else {
333
338
return None ;
@@ -352,11 +357,12 @@ fn closing_brace_hints(
352
357
return None ;
353
358
}
354
359
360
+ let linked_location = name_range. map ( |range| FileRange { file_id, range } ) ;
355
361
acc. push ( InlayHint {
356
362
range : closing_token. text_range ( ) ,
357
363
kind : InlayKind :: ClosingBraceHint ,
358
- label : label. into ( ) ,
359
- tooltip : name_offset . map ( |it| InlayTooltip :: HoverOffset ( file_id , it ) ) ,
364
+ label : InlayHintLabel { parts : vec ! [ InlayHintLabelPart { text : label, linked_location } ] } ,
365
+ tooltip : None , // provided by label part location
360
366
} ) ;
361
367
362
368
None
0 commit comments