fix: move dir on rename mod

This commit is contained in:
rainy-me 2022-04-12 23:01:53 +09:00
parent 5fe366c649
commit 3dd581b97d
5 changed files with 106 additions and 13 deletions

View file

@ -963,15 +963,21 @@ mod fo$0o;
},
},
file_system_edits: [
MoveFile {
src: FileId(
MoveDir {
src: AnchoredPathBuf {
anchor: FileId(
1,
),
path: "foo",
},
src_id: FileId(
1,
),
dst: AnchoredPathBuf {
anchor: FileId(
1,
),
path: "../foo2/mod.rs",
path: "foo2",
},
},
],
@ -1108,6 +1114,68 @@ pub mod foo$0;
);
}
#[test]
fn test_rename_mod_recursive() {
check_expect(
"foo2",
r#"
//- /lib.rs
mod foo$0;
//- /foo.rs
mod bar;
mod corge;
//- /foo/bar.rs
mod qux;
//- /foo/bar/qux.rs
mod quux;
//- /foo/bar/qux/quux/mod.rs
// empty
//- /foo/corge.rs
// empty
"#,
expect![[r#"
SourceChange {
source_file_edits: {
FileId(
0,
): TextEdit {
indels: [
Indel {
insert: "foo2",
delete: 4..7,
},
],
},
},
file_system_edits: [
MoveDir {
src: AnchoredPathBuf {
anchor: FileId(
1,
),
path: "foo",
},
src_id: FileId(
1,
),
dst: AnchoredPathBuf {
anchor: FileId(
1,
),
path: "foo2",
},
},
],
is_snippet: false,
}
"#]],
)
}
#[test]
fn test_rename_mod_ref_by_super() {
check(