diff options
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r-- | crates/ra_ide/src/references/rename.rs | 59 |
1 files changed, 53 insertions, 6 deletions
diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs index bbf475f66..8735ec53c 100644 --- a/crates/ra_ide/src/references/rename.rs +++ b/crates/ra_ide/src/references/rename.rs | |||
@@ -116,8 +116,7 @@ fn rename_mod( | |||
116 | } else { | 116 | } else { |
117 | format!("{}.rs", new_name) | 117 | format!("{}.rs", new_name) |
118 | }; | 118 | }; |
119 | let move_file = | 119 | let move_file = FileSystemEdit::MoveFile { src: file_id, anchor: file_id, dst }; |
120 | FileSystemEdit::MoveFile { src: file_id, anchor: position.file_id, dst }; | ||
121 | file_system_edits.push(move_file); | 120 | file_system_edits.push(move_file); |
122 | } | 121 | } |
123 | ModuleSource::Module(..) => {} | 122 | ModuleSource::Module(..) => {} |
@@ -621,7 +620,7 @@ mod foo<|>; | |||
621 | 3, | 620 | 3, |
622 | ), | 621 | ), |
623 | anchor: FileId( | 622 | anchor: FileId( |
624 | 2, | 623 | 3, |
625 | ), | 624 | ), |
626 | dst: "foo2.rs", | 625 | dst: "foo2.rs", |
627 | }, | 626 | }, |
@@ -687,7 +686,7 @@ use crate::foo<|>::FooContent; | |||
687 | 2, | 686 | 2, |
688 | ), | 687 | ), |
689 | anchor: FileId( | 688 | anchor: FileId( |
690 | 3, | 689 | 2, |
691 | ), | 690 | ), |
692 | dst: "quux.rs", | 691 | dst: "quux.rs", |
693 | }, | 692 | }, |
@@ -734,7 +733,7 @@ mod fo<|>o; | |||
734 | 2, | 733 | 2, |
735 | ), | 734 | ), |
736 | anchor: FileId( | 735 | anchor: FileId( |
737 | 1, | 736 | 2, |
738 | ), | 737 | ), |
739 | dst: "../foo2/mod.rs", | 738 | dst: "../foo2/mod.rs", |
740 | }, | 739 | }, |
@@ -747,6 +746,54 @@ mod fo<|>o; | |||
747 | } | 746 | } |
748 | 747 | ||
749 | #[test] | 748 | #[test] |
749 | fn test_rename_unusually_nested_mod() { | ||
750 | check_expect( | ||
751 | "bar", | ||
752 | r#" | ||
753 | //- /lib.rs | ||
754 | mod outer { mod fo<|>o; } | ||
755 | |||
756 | //- /outer/foo.rs | ||
757 | // emtpy | ||
758 | "#, | ||
759 | expect![[r#" | ||
760 | RangeInfo { | ||
761 | range: 16..19, | ||
762 | info: SourceChange { | ||
763 | source_file_edits: [ | ||
764 | SourceFileEdit { | ||
765 | file_id: FileId( | ||
766 | 1, | ||
767 | ), | ||
768 | edit: TextEdit { | ||
769 | indels: [ | ||
770 | Indel { | ||
771 | insert: "bar", | ||
772 | delete: 16..19, | ||
773 | }, | ||
774 | ], | ||
775 | }, | ||
776 | }, | ||
777 | ], | ||
778 | file_system_edits: [ | ||
779 | MoveFile { | ||
780 | src: FileId( | ||
781 | 2, | ||
782 | ), | ||
783 | anchor: FileId( | ||
784 | 2, | ||
785 | ), | ||
786 | dst: "bar.rs", | ||
787 | }, | ||
788 | ], | ||
789 | is_snippet: false, | ||
790 | }, | ||
791 | } | ||
792 | "#]], | ||
793 | ); | ||
794 | } | ||
795 | |||
796 | #[test] | ||
750 | fn test_module_rename_in_path() { | 797 | fn test_module_rename_in_path() { |
751 | check( | 798 | check( |
752 | "baz", | 799 | "baz", |
@@ -818,7 +865,7 @@ pub mod foo<|>; | |||
818 | 3, | 865 | 3, |
819 | ), | 866 | ), |
820 | anchor: FileId( | 867 | anchor: FileId( |
821 | 2, | 868 | 3, |
822 | ), | 869 | ), |
823 | dst: "foo2.rs", | 870 | dst: "foo2.rs", |
824 | }, | 871 | }, |