@@ -323,9 +323,7 @@ fn render_resolution_path(
323323 ..CompletionRelevance :: default ( )
324324 } ) ;
325325
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) ;
329327 } ;
330328 item
331329}
@@ -453,6 +451,29 @@ fn compute_ref_match(
453451 None
454452}
455453
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+
456477#[ cfg( test) ]
457478mod tests {
458479 use std:: cmp;
0 commit comments