diff options
Diffstat (limited to 'crates/assists/src/handlers/auto_import.rs')
-rw-r--r-- | crates/assists/src/handlers/auto_import.rs | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/crates/assists/src/handlers/auto_import.rs b/crates/assists/src/handlers/auto_import.rs index b5eb2c722..ee7277c04 100644 --- a/crates/assists/src/handlers/auto_import.rs +++ b/crates/assists/src/handlers/auto_import.rs | |||
@@ -196,10 +196,10 @@ impl AutoImportAssets { | |||
196 | }) | 196 | }) |
197 | .filter_map(|candidate| match candidate { | 197 | .filter_map(|candidate| match candidate { |
198 | Either::Left(module_def) => { | 198 | Either::Left(module_def) => { |
199 | self.module_with_name_to_import.find_use_path(db, module_def) | 199 | self.module_with_name_to_import.find_use_path_prefixed(db, module_def) |
200 | } | 200 | } |
201 | Either::Right(macro_def) => { | 201 | Either::Right(macro_def) => { |
202 | self.module_with_name_to_import.find_use_path(db, macro_def) | 202 | self.module_with_name_to_import.find_use_path_prefixed(db, macro_def) |
203 | } | 203 | } |
204 | }) | 204 | }) |
205 | .filter(|use_path| !use_path.segments.is_empty()) | 205 | .filter(|use_path| !use_path.segments.is_empty()) |
@@ -291,6 +291,35 @@ mod tests { | |||
291 | use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target}; | 291 | use crate::tests::{check_assist, check_assist_not_applicable, check_assist_target}; |
292 | 292 | ||
293 | #[test] | 293 | #[test] |
294 | fn applicable_when_found_an_import_partial() { | ||
295 | check_assist( | ||
296 | auto_import, | ||
297 | r" | ||
298 | mod std { | ||
299 | pub mod fmt { | ||
300 | pub struct Formatter; | ||
301 | } | ||
302 | } | ||
303 | |||
304 | use std::fmt; | ||
305 | |||
306 | <|>Formatter | ||
307 | ", | ||
308 | r" | ||
309 | mod std { | ||
310 | pub mod fmt { | ||
311 | pub struct Formatter; | ||
312 | } | ||
313 | } | ||
314 | |||
315 | use std::fmt::{self, Formatter}; | ||
316 | |||
317 | Formatter | ||
318 | ", | ||
319 | ); | ||
320 | } | ||
321 | |||
322 | #[test] | ||
294 | fn applicable_when_found_an_import() { | 323 | fn applicable_when_found_an_import() { |
295 | check_assist( | 324 | check_assist( |
296 | auto_import, | 325 | auto_import, |