@@ -724,11 +724,8 @@ fn orig_range_with_focus(
724724) -> UpmappingResult < ( FileRange , Option < TextRange > ) > {
725725 let Some ( name) = name else { return orig_range ( db, hir_file, value) } ;
726726
727- let call_range = || {
728- db. lookup_intern_macro_call ( hir_file. macro_file ( ) . unwrap ( ) . macro_call_id )
729- . kind
730- . original_call_range ( db)
731- } ;
727+ let call_kind =
728+ || db. lookup_intern_macro_call ( hir_file. macro_file ( ) . unwrap ( ) . macro_call_id ) . kind ;
732729
733730 let def_range = || {
734731 db. lookup_intern_macro_call ( hir_file. macro_file ( ) . unwrap ( ) . macro_call_id )
@@ -755,7 +752,22 @@ fn orig_range_with_focus(
755752 }
756753 // name lies outside the node, so instead point to the macro call which
757754 // *should* contain the name
758- _ => call_range ( ) ,
755+ _ => {
756+ let kind = call_kind ( ) ;
757+ let range = kind. clone ( ) . original_call_range_with_body ( db) ;
758+ //If the focus range is in the attribute/derive body, we
759+ // need to point the call site to the entire body, if not, fall back
760+ // to the name range of the attribute/derive call
761+ // FIXME: Do this differently, this is very inflexible the caller
762+ // should choose this behavior
763+ if range. file_id == focus_range. file_id
764+ && range. range . contains_range ( focus_range. range )
765+ {
766+ range
767+ } else {
768+ kind. original_call_range ( db)
769+ }
770+ }
759771 } ,
760772 Some ( focus_range) ,
761773 ) ,
@@ -784,7 +796,7 @@ fn orig_range_with_focus(
784796 // node is in macro def, just show the focus
785797 _ => (
786798 // show the macro call
787- ( call_range ( ) , None ) ,
799+ ( call_kind ( ) . original_call_range ( db ) , None ) ,
788800 Some ( ( focus_range, Some ( focus_range) ) ) ,
789801 ) ,
790802 }
0 commit comments