mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 21:43:37 +00:00
Merge #6563
6563: Don't complete keywords in struct initializers r=matklad a=Veykril Fixes #6562 Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
commit
789d9ca1d3
1 changed files with 46 additions and 0 deletions
|
@ -44,6 +44,10 @@ pub(crate) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte
|
||||||
mark::hit!(no_keyword_completion_in_comments);
|
mark::hit!(no_keyword_completion_in_comments);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if ctx.record_lit_syntax.is_some() {
|
||||||
|
mark::hit!(no_keyword_completion_in_record_lit);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let has_trait_or_impl_parent = ctx.has_impl_parent || ctx.has_trait_parent;
|
let has_trait_or_impl_parent = ctx.has_impl_parent || ctx.has_trait_parent;
|
||||||
if ctx.trait_as_prev_sibling || ctx.impl_as_prev_sibling {
|
if ctx.trait_as_prev_sibling || ctx.impl_as_prev_sibling {
|
||||||
|
@ -563,4 +567,46 @@ struct Foo {
|
||||||
"#]],
|
"#]],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn skip_struct_initializer() {
|
||||||
|
mark::check!(no_keyword_completion_in_record_lit);
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
struct Foo {
|
||||||
|
pub f: i32,
|
||||||
|
}
|
||||||
|
fn foo() {
|
||||||
|
Foo {
|
||||||
|
<|>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
expect![[r#""#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn struct_initializer_field_expr() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
struct Foo {
|
||||||
|
pub f: i32,
|
||||||
|
}
|
||||||
|
fn foo() {
|
||||||
|
Foo {
|
||||||
|
f: <|>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
kw if
|
||||||
|
kw if let
|
||||||
|
kw loop
|
||||||
|
kw match
|
||||||
|
kw return
|
||||||
|
kw while
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue