Skip to content

Commit 90e2db8

Browse files
committed
fix: Fix item completions not working properly after unit structs and outline modules
1 parent 1cb6ab8 commit 90e2db8

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

crates/ide-completion/src/context/analysis.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -681,9 +681,13 @@ fn classify_name_ref(
681681
ast::Item::ExternBlock(it) => it.extern_item_list().is_none(),
682682
ast::Item::Fn(it) => it.body().is_none(),
683683
ast::Item::Impl(it) => it.assoc_item_list().is_none(),
684-
ast::Item::Module(it) => it.item_list().is_none(),
684+
ast::Item::Module(it) => {
685+
it.item_list().is_none() && it.semicolon_token().is_none()
686+
}
685687
ast::Item::Static(it) => it.body().is_none(),
686-
ast::Item::Struct(it) => it.field_list().is_none(),
688+
ast::Item::Struct(it) => {
689+
it.field_list().is_none() && it.semicolon_token().is_none()
690+
}
687691
ast::Item::Trait(it) => it.assoc_item_list().is_none(),
688692
ast::Item::TypeAlias(it) => it.ty().is_none(),
689693
ast::Item::Union(it) => it.record_field_list().is_none(),

crates/ide-completion/src/tests/item_list.rs

+32
Original file line numberDiff line numberDiff line change
@@ -245,3 +245,35 @@ impl Test for () {
245245
"#]],
246246
);
247247
}
248+
249+
#[test]
250+
fn after_unit_struct() {
251+
check(
252+
r#"struct S; f$0"#,
253+
expect![[r#"
254+
ma makro!(…) macro_rules! makro
255+
md module
256+
kw const
257+
kw crate::
258+
kw enum
259+
kw extern
260+
kw fn
261+
kw impl
262+
kw mod
263+
kw pub
264+
kw pub(crate)
265+
kw pub(super)
266+
kw self::
267+
kw static
268+
kw struct
269+
kw trait
270+
kw type
271+
kw union
272+
kw unsafe
273+
kw use
274+
sn macro_rules
275+
sn tfn (Test function)
276+
sn tmod (Test module)
277+
"#]],
278+
);
279+
}

0 commit comments

Comments
 (0)