From d1ac3293f4aa0f0807cfb9a9d5337c6a4a2632d7 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sun, 17 Jan 2021 02:52:36 +0200 Subject: Properly resolve completion edits for empty input --- crates/completion/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'crates/completion/src/lib.rs') diff --git a/crates/completion/src/lib.rs b/crates/completion/src/lib.rs index 56ec13e8c..2c4e54524 100644 --- a/crates/completion/src/lib.rs +++ b/crates/completion/src/lib.rs @@ -11,10 +11,10 @@ mod render; mod completions; +use completions::flyimport::position_for_import; use ide_db::{ base_db::FilePosition, helpers::insert_use::ImportScope, imports_locator, RootDatabase, }; -use syntax::AstNode; use text_edit::TextEdit; use crate::{completions::Completions, context::CompletionContext, item::CompletionKind}; @@ -142,10 +142,10 @@ pub fn resolve_completion_edits( import_for_trait_assoc_item: bool, ) -> Option> { let ctx = CompletionContext::new(db, position, config)?; - let anchor = ctx.name_ref_syntax.as_ref()?; - let import_scope = ImportScope::find_insert_use_container(anchor.syntax(), &ctx.sema)?; + let position_for_import = position_for_import(&ctx, None)?; + let import_scope = ImportScope::find_insert_use_container(position_for_import, &ctx.sema)?; - let current_module = ctx.sema.scope(anchor.syntax()).module()?; + let current_module = ctx.sema.scope(position_for_import).module()?; let current_crate = current_module.krate(); let import_path = imports_locator::find_exact_imports(&ctx.sema, current_crate, imported_name) -- cgit v1.2.3