From bed12833cc4ce7c6b4085ba8dc47fc167c83f8ea Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Tue, 19 Jan 2021 20:01:49 +0100 Subject: Show const params in completions --- .../completion/src/completions/unqualified_path.rs | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'crates/completion/src/completions/unqualified_path.rs') diff --git a/crates/completion/src/completions/unqualified_path.rs b/crates/completion/src/completions/unqualified_path.rs index ac5596ca4..809e1645a 100644 --- a/crates/completion/src/completions/unqualified_path.rs +++ b/crates/completion/src/completions/unqualified_path.rs @@ -29,6 +29,10 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC } ctx.scope.process_all_names(&mut |name, res| { + if let ScopeDef::GenericParam(hir::GenericParam::LifetimeParam(_)) = res { + mark::hit!(skip_lifetime_completion); + return; + } if ctx.use_item_syntax.is_some() { if let (ScopeDef::Unknown, Some(name_ref)) = (&res, &ctx.name_ref_syntax) { if name_ref.syntax().text() == name.to_string().as_str() { @@ -37,7 +41,7 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC } } } - acc.add_resolution(ctx, name.to_string(), &res) + acc.add_resolution(ctx, name.to_string(), &res); }); } @@ -234,6 +238,24 @@ fn main() { fn quux() fn quux() "#]], ); + check( + r#"fn quux() { $0 }"#, + expect![[r#" + tp C + fn quux() fn quux() + "#]], + ); + } + + #[test] + fn does_not_complete_lifetimes() { + mark::check!(skip_lifetime_completion); + check( + r#"fn quux<'a>() { $0 }"#, + expect![[r#" + fn quux() fn quux<'a>() + "#]], + ); } #[test] -- cgit v1.2.3