@@ -724,11 +724,8 @@ fn orig_range_with_focus(
724
724
) -> UpmappingResult < ( FileRange , Option < TextRange > ) > {
725
725
let Some ( name) = name else { return orig_range ( db, hir_file, value) } ;
726
726
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 ;
732
729
733
730
let def_range = || {
734
731
db. lookup_intern_macro_call ( hir_file. macro_file ( ) . unwrap ( ) . macro_call_id )
@@ -755,7 +752,22 @@ fn orig_range_with_focus(
755
752
}
756
753
// name lies outside the node, so instead point to the macro call which
757
754
// *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
+ }
759
771
} ,
760
772
Some ( focus_range) ,
761
773
) ,
@@ -784,7 +796,7 @@ fn orig_range_with_focus(
784
796
// node is in macro def, just show the focus
785
797
_ => (
786
798
// show the macro call
787
- ( call_range ( ) , None ) ,
799
+ ( call_kind ( ) . original_call_range ( db ) , None ) ,
788
800
Some ( ( focus_range, Some ( focus_range) ) ) ,
789
801
) ,
790
802
}
0 commit comments