diff options
author | Lukas Wirth <[email protected]> | 2021-05-27 20:12:50 +0100 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-05-27 20:12:50 +0100 |
commit | ea251cbd4a22c7754bb5668b9f25fc0c7b47284c (patch) | |
tree | 5956fa2300defdc96f1ecb294db77a1705561527 /crates/ide_completion/src/completions/unqualified_path.rs | |
parent | 7ad378fec06dae4ba2417f2a109e4759bbcf75db (diff) |
Complete modules in item lists
Diffstat (limited to 'crates/ide_completion/src/completions/unqualified_path.rs')
-rw-r--r-- | crates/ide_completion/src/completions/unqualified_path.rs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/crates/ide_completion/src/completions/unqualified_path.rs b/crates/ide_completion/src/completions/unqualified_path.rs index dc93e368d..c901b358b 100644 --- a/crates/ide_completion/src/completions/unqualified_path.rs +++ b/crates/ide_completion/src/completions/unqualified_path.rs | |||
@@ -9,10 +9,10 @@ pub(crate) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionC | |||
9 | if !ctx.is_trivial_path { | 9 | if !ctx.is_trivial_path { |
10 | return; | 10 | return; |
11 | } | 11 | } |
12 | if ctx.is_path_disallowed() { | 12 | if ctx.is_path_disallowed() || ctx.expects_item() { |
13 | return; | 13 | return; |
14 | } | 14 | } |
15 | if ctx.expects_item() || ctx.expects_assoc_item() { | 15 | if ctx.expects_assoc_item() { |
16 | ctx.scope.process_all_names(&mut |name, def| { | 16 | ctx.scope.process_all_names(&mut |name, def| { |
17 | if let ScopeDef::MacroDef(macro_def) = def { | 17 | if let ScopeDef::MacroDef(macro_def) = def { |
18 | acc.add_macro(ctx, Some(name.to_string()), macro_def); | 18 | acc.add_macro(ctx, Some(name.to_string()), macro_def); |
@@ -692,4 +692,22 @@ impl MyStruct { | |||
692 | "#]], | 692 | "#]], |
693 | ) | 693 | ) |
694 | } | 694 | } |
695 | |||
696 | // FIXME: The completions here currently come from `macro_in_item_position`, but they shouldn't | ||
697 | #[test] | ||
698 | fn completes_in_item_list() { | ||
699 | check( | ||
700 | r#" | ||
701 | struct MyStruct {} | ||
702 | macro_rules! foo {} | ||
703 | mod bar {} | ||
704 | |||
705 | $0 | ||
706 | "#, | ||
707 | expect![[r#" | ||
708 | md bar | ||
709 | ma foo!(…) macro_rules! foo | ||
710 | "#]], | ||
711 | ) | ||
712 | } | ||
695 | } | 713 | } |