File tree Expand file tree Collapse file tree 1 file changed +34
-1
lines changed
crates/ide_assists/src/handlers Expand file tree Collapse file tree 1 file changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -84,12 +84,12 @@ pub(crate) fn replace_qualified_name_with_use(
84
84
ImportScope :: Module ( it) => ImportScope :: Module ( builder. make_mut ( it) ) ,
85
85
ImportScope :: Block ( it) => ImportScope :: Block ( builder. make_mut ( it) ) ,
86
86
} ;
87
+ shorten_paths ( scope. as_syntax_node ( ) , & path. clone_for_update ( ) ) ;
87
88
// stick the found import in front of the to be replaced path
88
89
let path = match path_to_qualifier. and_then ( |it| mod_path_to_ast ( & it) . qualifier ( ) ) {
89
90
Some ( qualifier) => make:: path_concat ( qualifier, path) ,
90
91
None => path,
91
92
} ;
92
- shorten_paths ( scope. as_syntax_node ( ) , & path. clone_for_update ( ) ) ;
93
93
insert_use ( & scope, path, & ctx. config . insert_use ) ;
94
94
} ,
95
95
)
@@ -356,6 +356,39 @@ mod bar {
356
356
fn main() {
357
357
Foo;
358
358
}
359
+ " ,
360
+ ) ;
361
+ }
362
+
363
+ #[ test]
364
+ fn replace_does_not_always_try_to_replace_by_full_item_path ( ) {
365
+ check_assist (
366
+ replace_qualified_name_with_use,
367
+ r"
368
+ use std::mem;
369
+
370
+ mod std {
371
+ pub mod mem {
372
+ pub fn drop<T>(_: T) {}
373
+ }
374
+ }
375
+
376
+ fn main() {
377
+ mem::drop$0(0);
378
+ }
379
+ " ,
380
+ r"
381
+ use std::mem::{self, drop};
382
+
383
+ mod std {
384
+ pub mod mem {
385
+ pub fn drop<T>(_: T) {}
386
+ }
387
+ }
388
+
389
+ fn main() {
390
+ drop(0);
391
+ }
359
392
" ,
360
393
) ;
361
394
}
You can’t perform that action at this time.
0 commit comments