diff options
author | Lukas Wirth <[email protected]> | 2021-05-27 03:34:21 +0100 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-05-27 11:23:36 +0100 |
commit | f41c98342476087d0a4387e7d337ce2d897e0346 (patch) | |
tree | 1c9b8e9f5a3d26d921337f6f20501b38de6fcb94 /crates/ide_completion/src/patterns.rs | |
parent | 30948e1ecb2fb4fe35bf9c5c1e49464d4ea1d064 (diff) |
Don't complete non-macro item paths in impls and modules
Diffstat (limited to 'crates/ide_completion/src/patterns.rs')
-rw-r--r-- | crates/ide_completion/src/patterns.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/crates/ide_completion/src/patterns.rs b/crates/ide_completion/src/patterns.rs index 04f2c532b..f7bf4d638 100644 --- a/crates/ide_completion/src/patterns.rs +++ b/crates/ide_completion/src/patterns.rs | |||
@@ -92,9 +92,15 @@ fn test_has_ref_parent() { | |||
92 | } | 92 | } |
93 | 93 | ||
94 | pub(crate) fn has_item_list_or_source_file_parent(element: SyntaxElement) -> bool { | 94 | pub(crate) fn has_item_list_or_source_file_parent(element: SyntaxElement) -> bool { |
95 | match not_same_range_ancestor(element) { | 95 | let it = element |
96 | Some(it) => it.kind() == SOURCE_FILE || it.kind() == ITEM_LIST, | 96 | .ancestors() |
97 | None => true, | 97 | .take_while(|it| it.text_range() == element.text_range()) |
98 | .last() | ||
99 | .map(|it| (it.kind(), it.parent())); | ||
100 | match it { | ||
101 | Some((_, Some(it))) => it.kind() == SOURCE_FILE || it.kind() == ITEM_LIST, | ||
102 | Some((MACRO_ITEMS, None) | (SOURCE_FILE, None)) => true, | ||
103 | _ => false, | ||
98 | } | 104 | } |
99 | } | 105 | } |
100 | #[test] | 106 | #[test] |