File tree 2 files changed +17
-9
lines changed
rust-analyzer/src/handlers
2 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -424,7 +424,7 @@ fn ty_to_text_edit(
424
424
425
425
pub enum RangeLimit {
426
426
Fixed ( TextRange ) ,
427
- NearestParentBlock ( TextSize ) ,
427
+ NearestParent ( TextSize ) ,
428
428
}
429
429
430
430
// Feature: Inlay Hints
@@ -470,13 +470,21 @@ pub(crate) fn inlay_hints(
470
470
. filter ( |descendant| range. intersect ( descendant. text_range ( ) ) . is_some ( ) )
471
471
. for_each ( hints) ,
472
472
} ,
473
- Some ( RangeLimit :: NearestParentBlock ( position) ) => {
474
- match file
475
- . token_at_offset ( position)
476
- . left_biased ( )
477
- . and_then ( |token| token. parent_ancestors ( ) . find_map ( ast:: BlockExpr :: cast) )
478
- {
479
- Some ( parent_block) => parent_block. syntax ( ) . descendants ( ) . for_each ( hints) ,
473
+ Some ( RangeLimit :: NearestParent ( position) ) => {
474
+ match file. token_at_offset ( position) . left_biased ( ) {
475
+ Some ( token) => {
476
+ if let Some ( parent_block) =
477
+ token. parent_ancestors ( ) . find_map ( ast:: BlockExpr :: cast)
478
+ {
479
+ parent_block. syntax ( ) . descendants ( ) . for_each ( hints)
480
+ } else if let Some ( parent_item) =
481
+ token. parent_ancestors ( ) . find_map ( ast:: Item :: cast)
482
+ {
483
+ parent_item. syntax ( ) . descendants ( ) . for_each ( hints)
484
+ } else {
485
+ return acc;
486
+ }
487
+ }
480
488
None => return acc,
481
489
}
482
490
}
Original file line number Diff line number Diff line change @@ -1446,7 +1446,7 @@ pub(crate) fn handle_inlay_hints_resolve(
1446
1446
let resolve_hints = snap. analysis . inlay_hints (
1447
1447
& forced_resolve_inlay_hints_config,
1448
1448
file_id,
1449
- Some ( RangeLimit :: NearestParentBlock ( hint_position) ) ,
1449
+ Some ( RangeLimit :: NearestParent ( hint_position) ) ,
1450
1450
) ?;
1451
1451
1452
1452
let mut resolved_hints = resolve_hints
You can’t perform that action at this time.
0 commit comments