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> {
115
115
find_node_at_offset :: < ast:: MacroCall > ( & original_file, offset) ,
116
116
find_node_at_offset :: < ast:: MacroCall > ( & hypothetical_file, offset) ,
117
117
) {
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
+ }
118
123
if let ( Some ( actual_expansion) , Some ( hypothetical_expansion) ) = (
119
124
ctx. sema . expand ( & actual_macro_call) ,
120
125
ctx. sema . expand_hypothetical (
@@ -123,11 +128,15 @@ impl<'a> CompletionContext<'a> {
123
128
fake_ident_token,
124
129
) ,
125
130
) {
131
+ let new_offset = hypothetical_expansion. 1 . text_range ( ) . start ( ) ;
132
+ if new_offset >= actual_expansion. text_range ( ) . end ( ) {
133
+ break ;
134
+ }
126
135
// TODO check that the expansions 'look the same' up to the inserted token?
127
136
original_file = actual_expansion;
128
137
hypothetical_file = hypothetical_expansion. 0 ;
129
138
fake_ident_token = hypothetical_expansion. 1 ;
130
- offset = fake_ident_token . text_range ( ) . start ( ) ;
139
+ offset = new_offset ;
131
140
} else {
132
141
break ;
133
142
}
You can’t perform that action at this time.
0 commit comments