File tree Expand file tree Collapse file tree 1 file changed +4
-9
lines changed
src/tools/rust-analyzer/crates/ide-assists/src Expand file tree Collapse file tree 1 file changed +4
-9
lines changed Original file line number Diff line number Diff line change @@ -1155,17 +1155,12 @@ pub(crate) fn get_struct_definition_from_context(
11551155) -> Option < Either < ast:: Struct , ast:: Variant > > {
11561156 ctx. find_node_at_offset :: < ast:: Name > ( )
11571157 . and_then ( |name| name. syntax ( ) . parent ( ) )
1158- . or ( find_struct_keyword ( ctx) . and_then ( |kw| kw. parent ( ) ) )
1158+ . or ( ctx
1159+ . token_at_offset ( )
1160+ . find ( |leaf| matches ! ( leaf. kind( ) , STRUCT_KW ) )
1161+ . and_then ( |kw| kw. parent ( ) ) )
11591162 . or ( ctx
11601163 . find_node_at_offset :: < ast:: Visibility > ( )
11611164 . and_then ( |visibility| visibility. syntax ( ) . parent ( ) ) )
11621165 . and_then ( <Either < ast:: Struct , ast:: Variant > >:: cast)
11631166}
1164-
1165- fn find_struct_keyword ( ctx : & AssistContext < ' _ > ) -> Option < SyntaxToken > {
1166- // Attempt to find the token at the current cursor offset
1167- ctx. token_at_offset ( ) . find ( |leaf| match leaf. kind ( ) {
1168- STRUCT_KW => true ,
1169- _ => false ,
1170- } )
1171- }
You can’t perform that action at this time.
0 commit comments