@@ -3,7 +3,7 @@ use ide_db::SymbolKind;
33use syntax:: { ast:: Expr , T } ;
44
55use crate :: {
6- context:: { NameRefContext , PatternContext } ,
6+ context:: { NameRefContext , NameRefKind , PathCompletionCtx , PathKind , PatternContext } ,
77 CompletionContext , CompletionItem , CompletionItemKind , CompletionRelevance ,
88 CompletionRelevancePostfixMatch , Completions ,
99} ;
@@ -13,8 +13,18 @@ pub(crate) fn complete_record(acc: &mut Completions, ctx: &CompletionContext) ->
1313 & ctx. pattern_ctx
1414 {
1515 ctx. sema . record_pattern_missing_fields ( record_pat)
16- } else if let Some ( NameRefContext { record_expr : Some ( ( record_expr, _) ) , .. } ) =
17- ctx. nameref_ctx ( )
16+ } else if let Some ( NameRefContext {
17+ kind :
18+ Some (
19+ NameRefKind :: RecordExpr ( record_expr)
20+ | NameRefKind :: Path ( PathCompletionCtx {
21+ kind : PathKind :: Expr { is_func_update : Some ( record_expr) , .. } ,
22+ qualifier : None ,
23+ ..
24+ } ) ,
25+ ) ,
26+ ..
27+ } ) = ctx. nameref_ctx ( )
1828 {
1929 let ty = ctx. sema . type_of_expr ( & Expr :: RecordExpr ( record_expr. clone ( ) ) ) ;
2030
@@ -39,7 +49,7 @@ pub(crate) fn complete_record(acc: &mut Completions, ctx: &CompletionContext) ->
3949 ty. original . impls_trait ( ctx. db , default_trait, & [ ] )
4050 } ) ;
4151
42- if impl_default_trait && !missing_fields. is_empty ( ) && ctx . path_qual ( ) . is_none ( ) {
52+ if impl_default_trait && !missing_fields. is_empty ( ) {
4353 let completion_text = "..Default::default()" ;
4454 let mut item =
4555 CompletionItem :: new ( SymbolKind :: Field , ctx. source_range ( ) , completion_text) ;
0 commit comments