File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed
crates/completion/src/completions Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,10 @@ pub(crate) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte
4444 mark:: hit!( no_keyword_completion_in_comments) ;
4545 return ;
4646 }
47+ if ctx. record_lit_syntax . is_some ( ) {
48+ mark:: hit!( no_keyword_completion_in_record_lit) ;
49+ return ;
50+ }
4751
4852 let has_trait_or_impl_parent = ctx. has_impl_parent || ctx. has_trait_parent ;
4953 if ctx. trait_as_prev_sibling || ctx. impl_as_prev_sibling {
@@ -563,4 +567,46 @@ struct Foo {
563567 "# ] ] ,
564568 )
565569 }
570+
571+ #[ test]
572+ fn skip_struct_initializer ( ) {
573+ mark:: check!( no_keyword_completion_in_record_lit) ;
574+ check (
575+ r#"
576+ struct Foo {
577+ pub f: i32,
578+ }
579+ fn foo() {
580+ Foo {
581+ <|>
582+ }
583+ }
584+ "# ,
585+ expect ! [ [ r#""# ] ] ,
586+ ) ;
587+ }
588+
589+ #[ test]
590+ fn struct_initializer_field_expr ( ) {
591+ check (
592+ r#"
593+ struct Foo {
594+ pub f: i32,
595+ }
596+ fn foo() {
597+ Foo {
598+ f: <|>
599+ }
600+ }
601+ "# ,
602+ expect ! [ [ r#"
603+ kw if
604+ kw if let
605+ kw loop
606+ kw match
607+ kw return
608+ kw while
609+ "# ] ] ,
610+ ) ;
611+ }
566612}
You can’t perform that action at this time.
0 commit comments