Skip to content

Commit

Permalink
Don't parse files in module completion
Browse files Browse the repository at this point in the history
  • Loading branch information
Veykril committed May 10, 2022
1 parent 26fef97 commit 40bb800
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions crates/ide-completion/src/completions/mod_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ use crate::{
/// Complete mod declaration, i.e. `mod $0;`
pub(crate) fn complete_mod(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
let mod_under_caret = match ctx.name_ctx() {
Some(NameContext { kind: NameKind::Module(mod_under_caret), .. })
if mod_under_caret.item_list().is_none() =>
{
mod_under_caret
}
Some(NameContext { kind: NameKind::Module(mod_under_caret), .. }) => mod_under_caret,
_ => return None,
};
if mod_under_caret.item_list().is_some() {
return None;
}

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

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

0 comments on commit 40bb800

Please sign in to comment.