From ea251cbd4a22c7754bb5668b9f25fc0c7b47284c Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 27 May 2021 21:12:50 +0200 Subject: Complete modules in item lists --- .../src/completions/qualified_path.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'crates/ide_completion/src/completions/qualified_path.rs') diff --git a/crates/ide_completion/src/completions/qualified_path.rs b/crates/ide_completion/src/completions/qualified_path.rs index 4aa37df91..7a0e1ead3 100644 --- a/crates/ide_completion/src/completions/qualified_path.rs +++ b/crates/ide_completion/src/completions/qualified_path.rs @@ -7,7 +7,7 @@ use syntax::AstNode; use crate::{CompletionContext, Completions}; pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionContext) { - if ctx.is_path_disallowed() { + if ctx.is_path_disallowed() || ctx.expects_item() { return; } let path = match &ctx.path_qual { @@ -20,7 +20,7 @@ pub(crate) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon None => return, }; let context_module = ctx.scope.module(); - if ctx.expects_item() || ctx.expects_assoc_item() { + if ctx.expects_assoc_item() { if let PathResolution::Def(hir::ModuleDef::Module(module)) = resolution { let module_scope = module.scope(ctx.db, context_module); for (name, def) in module_scope { @@ -636,6 +636,24 @@ impl MyStruct { ); } + #[test] + #[ignore] // FIXME doesn't complete anything atm + fn completes_in_item_list() { + check( + r#" +struct MyStruct {} +macro_rules! foo {} +mod bar {} + +crate::$0 +"#, + expect![[r#" + md bar + ma foo! macro_rules! foo + "#]], + ) + } + #[test] fn test_super_super_completion() { check( -- cgit v1.2.3