@@ -323,9 +323,7 @@ fn render_resolution_path(
323
323
..CompletionRelevance :: default ( )
324
324
} ) ;
325
325
326
- if let Some ( ref_match) = compute_ref_match ( completion, & ty) {
327
- item. ref_match ( ref_match, path_ctx. path . syntax ( ) . text_range ( ) . start ( ) ) ;
328
- }
326
+ path_ref_match ( completion, path_ctx, & ty, & mut item) ;
329
327
} ;
330
328
item
331
329
}
@@ -453,6 +451,29 @@ fn compute_ref_match(
453
451
None
454
452
}
455
453
454
+ fn path_ref_match (
455
+ completion : & CompletionContext < ' _ > ,
456
+ path_ctx : & PathCompletionCtx ,
457
+ ty : & hir:: Type ,
458
+ item : & mut Builder ,
459
+ ) {
460
+ if let Some ( original_path) = & path_ctx. original_path {
461
+ // At least one char was typed by the user already, in that case look for the original path
462
+ if let Some ( original_path) = completion. sema . original_ast_node ( original_path. clone ( ) ) {
463
+ if let Some ( ref_match) = compute_ref_match ( completion, ty) {
464
+ item. ref_match ( ref_match, original_path. syntax ( ) . text_range ( ) . start ( ) ) ;
465
+ }
466
+ }
467
+ } else {
468
+ // completion requested on an empty identifier, there is no path here yet.
469
+ // FIXME: This might create inconsistent completions where we show a ref match in macro inputs
470
+ // as long as nothing was typed yet
471
+ if let Some ( ref_match) = compute_ref_match ( completion, ty) {
472
+ item. ref_match ( ref_match, completion. position . offset ) ;
473
+ }
474
+ }
475
+ }
476
+
456
477
#[ cfg( test) ]
457
478
mod tests {
458
479
use std:: cmp;
0 commit comments