Skip to content

Commit 40bb800

Browse files
committed
Don't parse files in module completion
1 parent 26fef97 commit 40bb800

File tree

1 file changed

+6
-7
lines changed
  • crates/ide-completion/src/completions

1 file changed

+6
-7
lines changed

crates/ide-completion/src/completions/mod_.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@ use crate::{
1717
/// Complete mod declaration, i.e. `mod $0;`
1818
pub(crate) fn complete_mod(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
1919
let mod_under_caret = match ctx.name_ctx() {
20-
Some(NameContext { kind: NameKind::Module(mod_under_caret), .. })
21-
if mod_under_caret.item_list().is_none() =>
22-
{
23-
mod_under_caret
24-
}
20+
Some(NameContext { kind: NameKind::Module(mod_under_caret), .. }) => mod_under_caret,
2521
_ => return None,
2622
};
23+
if mod_under_caret.item_list().is_some() {
24+
return None;
25+
}
2726

2827
let _p = profile::span("completion::complete_mod");
2928

@@ -32,8 +31,8 @@ pub(crate) fn complete_mod(acc: &mut Completions, ctx: &CompletionContext) -> Op
3231
// interested in its parent.
3332
if ctx.original_token.kind() == SyntaxKind::IDENT {
3433
if let Some(module) = ctx.original_token.ancestors().nth(1).and_then(ast::Module::cast) {
35-
match current_module.definition_source(ctx.db).value {
36-
ModuleSource::Module(src) if src == module => {
34+
match ctx.sema.to_def(&module) {
35+
Some(module) if module == current_module => {
3736
if let Some(parent) = current_module.parent(ctx.db) {
3837
current_module = parent;
3938
}

0 commit comments

Comments
 (0)