File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
crates/ra_ide/src/completion Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -115,6 +115,11 @@ impl<'a> CompletionContext<'a> {
115115 find_node_at_offset :: < ast:: MacroCall > ( & original_file, offset) ,
116116 find_node_at_offset :: < ast:: MacroCall > ( & hypothetical_file, offset) ,
117117 ) {
118+ if actual_macro_call. path ( ) . as_ref ( ) . map ( |s| s. syntax ( ) . text ( ) )
119+ != macro_call_with_fake_ident. path ( ) . as_ref ( ) . map ( |s| s. syntax ( ) . text ( ) )
120+ {
121+ break ;
122+ }
118123 if let ( Some ( actual_expansion) , Some ( hypothetical_expansion) ) = (
119124 ctx. sema . expand ( & actual_macro_call) ,
120125 ctx. sema . expand_hypothetical (
@@ -123,11 +128,15 @@ impl<'a> CompletionContext<'a> {
123128 fake_ident_token,
124129 ) ,
125130 ) {
131+ let new_offset = hypothetical_expansion. 1 . text_range ( ) . start ( ) ;
132+ if new_offset >= actual_expansion. text_range ( ) . end ( ) {
133+ break ;
134+ }
126135 // TODO check that the expansions 'look the same' up to the inserted token?
127136 original_file = actual_expansion;
128137 hypothetical_file = hypothetical_expansion. 0 ;
129138 fake_ident_token = hypothetical_expansion. 1 ;
130- offset = fake_ident_token . text_range ( ) . start ( ) ;
139+ offset = new_offset ;
131140 } else {
132141 break ;
133142 }
You can’t perform that action at this time.
0 commit comments