This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-9
lines changed
rust-analyzer/src/handlers Expand file tree Collapse file tree 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(
424424
425425pub enum RangeLimit {
426426 Fixed ( TextRange ) ,
427- NearestParentBlock ( TextSize ) ,
427+ NearestParent ( TextSize ) ,
428428}
429429
430430// Feature: Inlay Hints
@@ -470,13 +470,21 @@ pub(crate) fn inlay_hints(
470470 . filter ( |descendant| range. intersect ( descendant. text_range ( ) ) . is_some ( ) )
471471 . for_each ( hints) ,
472472 } ,
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+ }
480488 None => return acc,
481489 }
482490 }
Original file line number Diff line number Diff line change @@ -1446,7 +1446,7 @@ pub(crate) fn handle_inlay_hints_resolve(
14461446 let resolve_hints = snap. analysis . inlay_hints (
14471447 & forced_resolve_inlay_hints_config,
14481448 file_id,
1449- Some ( RangeLimit :: NearestParentBlock ( hint_position) ) ,
1449+ Some ( RangeLimit :: NearestParent ( hint_position) ) ,
14501450 ) ?;
14511451
14521452 let mut resolved_hints = resolve_hints
You can’t perform that action at this time.
0 commit comments