@@ -180,7 +180,6 @@ pub(crate) fn extract_module(acc: &mut Assists, ctx: &AssistContext) -> Option<(
180180 }
181181
182182 for import_path_text_range in import_paths_to_be_removed {
183- println ! ( "Deleting : {:?}" , import_path_text_range) ;
184183 builder. delete ( import_path_text_range) ;
185184 }
186185
@@ -565,12 +564,23 @@ impl Module {
565564 } else if exists_inside_sel && !exists_outside_sel {
566565 //Changes to be made inside new module, and remove import from outside
567566
568- if let Some ( ( use_tree_str, text_range_opt) ) =
567+ if let Some ( ( mut use_tree_str, text_range_opt) ) =
569568 self . process_use_stmt_for_import_resolve ( use_stmt_opt, node_syntax)
570569 {
571570 if let Some ( text_range) = text_range_opt {
572571 import_path_to_be_removed = Some ( text_range) ;
573572 }
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+
574584 use_tree_str_opt = Some ( use_tree_str) ;
575585 } else if source_exists_outside_sel_in_same_mod {
576586 self . make_use_stmt_of_node_with_super ( node_syntax) ;
@@ -580,9 +590,14 @@ impl Module {
580590 if let Some ( use_tree_str) = use_tree_str_opt {
581591 let mut use_tree_str = use_tree_str;
582592 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+ }
586601 }
587602
588603 let use_ =
0 commit comments