aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/patterns.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_completion/src/patterns.rs')
-rw-r--r--crates/ide_completion/src/patterns.rs12
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
94pub(crate) fn has_item_list_or_source_file_parent(element: SyntaxElement) -> bool { 94pub(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]