@@ -180,7 +180,6 @@ pub(crate) fn extract_module(acc: &mut Assists, ctx: &AssistContext) -> Option<(
180
180
}
181
181
182
182
for import_path_text_range in import_paths_to_be_removed {
183
- println ! ( "Deleting : {:?}" , import_path_text_range) ;
184
183
builder. delete ( import_path_text_range) ;
185
184
}
186
185
@@ -565,12 +564,23 @@ impl Module {
565
564
} else if exists_inside_sel && !exists_outside_sel {
566
565
//Changes to be made inside new module, and remove import from outside
567
566
568
- if let Some ( ( use_tree_str, text_range_opt) ) =
567
+ if let Some ( ( mut use_tree_str, text_range_opt) ) =
569
568
self . process_use_stmt_for_import_resolve ( use_stmt_opt, node_syntax)
570
569
{
571
570
if let Some ( text_range) = text_range_opt {
572
571
import_path_to_be_removed = Some ( text_range) ;
573
572
}
573
+
574
+ if source_exists_outside_sel_in_same_mod {
575
+ let first_path_in_use_tree = use_tree_str[ use_tree_str. len ( ) - 1 ] . to_string ( ) ;
576
+ if !first_path_in_use_tree. contains ( "super" )
577
+ && !first_path_in_use_tree. contains ( "crate" )
578
+ {
579
+ let super_path = make:: ext:: ident_path ( "super" ) ;
580
+ use_tree_str. push ( super_path) ;
581
+ }
582
+ }
583
+
574
584
use_tree_str_opt = Some ( use_tree_str) ;
575
585
} else if source_exists_outside_sel_in_same_mod {
576
586
self . make_use_stmt_of_node_with_super ( node_syntax) ;
@@ -580,9 +590,14 @@ impl Module {
580
590
if let Some ( use_tree_str) = use_tree_str_opt {
581
591
let mut use_tree_str = use_tree_str;
582
592
use_tree_str. reverse ( ) ;
583
- if use_tree_str[ 0 ] . to_string ( ) . contains ( "super" ) {
584
- let super_path = make:: ext:: ident_path ( "super" ) ;
585
- use_tree_str. insert ( 0 , super_path)
593
+
594
+ if !( !exists_outside_sel && exists_inside_sel && source_exists_outside_sel_in_same_mod)
595
+ {
596
+ let first_path_in_use_tree = use_tree_str[ 0 ] . to_string ( ) ;
597
+ if first_path_in_use_tree. contains ( "super" ) {
598
+ let super_path = make:: ext:: ident_path ( "super" ) ;
599
+ use_tree_str. insert ( 0 , super_path)
600
+ }
586
601
}
587
602
588
603
let use_ =
0 commit comments