From 1f028403cdbb35cf1dc23350819e6f4e1ebd057e Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 20 Jun 2022 18:02:13 +0200 Subject: [PATCH] fix: Don't trigger pattern completions when typing a wildcard pattern --- crates/ide-completion/src/completions.rs | 6 +++++- crates/ide-completion/src/tests/pattern.rs | 12 ++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/crates/ide-completion/src/completions.rs b/crates/ide-completion/src/completions.rs index a0725198f73..4f522ee7613 100644 --- a/crates/ide-completion/src/completions.rs +++ b/crates/ide-completion/src/completions.rs @@ -489,7 +489,11 @@ pub(super) fn complete_name( NameKind::Function => { item_list::trait_impl::complete_trait_impl_fn(acc, ctx, name); } - NameKind::IdentPat(pattern_ctx) => complete_patterns(acc, ctx, pattern_ctx), + NameKind::IdentPat(pattern_ctx) => { + if ctx.token.kind() != syntax::T![_] { + complete_patterns(acc, ctx, pattern_ctx) + } + } NameKind::Module(mod_under_caret) => { mod_::complete_mod(acc, ctx, mod_under_caret); } diff --git a/crates/ide-completion/src/tests/pattern.rs b/crates/ide-completion/src/tests/pattern.rs index d21f62f4adb..da9e5e20288 100644 --- a/crates/ide-completion/src/tests/pattern.rs +++ b/crates/ide-completion/src/tests/pattern.rs @@ -13,6 +13,18 @@ fn check(ra_fixture: &str, expect: Expect) { expect.assert_eq(&actual) } +#[test] +fn wildcard() { + check( + r#" +fn quux() { + let _$0 +} +"#, + expect![""], + ); +} + #[test] fn ident_rebind_pat() { check_empty(