aboutsummaryrefslogtreecommitdiff
path: root/crates/completion
diff options
context:
space:
mode:
Diffstat (limited to 'crates/completion')
-rw-r--r--crates/completion/src/completions/keyword.rs46
1 files changed, 46 insertions, 0 deletions
diff --git a/crates/completion/src/completions/keyword.rs b/crates/completion/src/completions/keyword.rs
index c7df15900..720349b9d 100644
--- a/crates/completion/src/completions/keyword.rs
+++ b/crates/completion/src/completions/keyword.rs
@@ -44,6 +44,10 @@ pub(crate) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte
44 mark::hit!(no_keyword_completion_in_comments); 44 mark::hit!(no_keyword_completion_in_comments);
45 return; 45 return;
46 } 46 }
47 if ctx.record_lit_syntax.is_some() {
48 mark::hit!(no_keyword_completion_in_record_lit);
49 return;
50 }
47 51
48 let has_trait_or_impl_parent = ctx.has_impl_parent || ctx.has_trait_parent; 52 let has_trait_or_impl_parent = ctx.has_impl_parent || ctx.has_trait_parent;
49 if ctx.trait_as_prev_sibling || ctx.impl_as_prev_sibling { 53 if ctx.trait_as_prev_sibling || ctx.impl_as_prev_sibling {
@@ -563,4 +567,46 @@ struct Foo {
563 "#]], 567 "#]],
564 ) 568 )
565 } 569 }
570
571 #[test]
572 fn skip_struct_initializer() {
573 mark::check!(no_keyword_completion_in_record_lit);
574 check(
575 r#"
576struct Foo {
577 pub f: i32,
578}
579fn 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#"
593struct Foo {
594 pub f: i32,
595}
596fn 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 }
566} 612}