mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Fix module renaming
This commit is contained in:
parent
4c347a9f65
commit
f4a3bc30b8
1 changed files with 53 additions and 6 deletions
|
@ -116,8 +116,7 @@ fn rename_mod(
|
|||
} else {
|
||||
format!("{}.rs", new_name)
|
||||
};
|
||||
let move_file =
|
||||
FileSystemEdit::MoveFile { src: file_id, anchor: position.file_id, dst };
|
||||
let move_file = FileSystemEdit::MoveFile { src: file_id, anchor: file_id, dst };
|
||||
file_system_edits.push(move_file);
|
||||
}
|
||||
ModuleSource::Module(..) => {}
|
||||
|
@ -621,7 +620,7 @@ mod foo<|>;
|
|||
3,
|
||||
),
|
||||
anchor: FileId(
|
||||
2,
|
||||
3,
|
||||
),
|
||||
dst: "foo2.rs",
|
||||
},
|
||||
|
@ -687,7 +686,7 @@ use crate::foo<|>::FooContent;
|
|||
2,
|
||||
),
|
||||
anchor: FileId(
|
||||
3,
|
||||
2,
|
||||
),
|
||||
dst: "quux.rs",
|
||||
},
|
||||
|
@ -734,7 +733,7 @@ mod fo<|>o;
|
|||
2,
|
||||
),
|
||||
anchor: FileId(
|
||||
1,
|
||||
2,
|
||||
),
|
||||
dst: "../foo2/mod.rs",
|
||||
},
|
||||
|
@ -746,6 +745,54 @@ mod fo<|>o;
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_rename_unusually_nested_mod() {
|
||||
check_expect(
|
||||
"bar",
|
||||
r#"
|
||||
//- /lib.rs
|
||||
mod outer { mod fo<|>o; }
|
||||
|
||||
//- /outer/foo.rs
|
||||
// emtpy
|
||||
"#,
|
||||
expect![[r#"
|
||||
RangeInfo {
|
||||
range: 16..19,
|
||||
info: SourceChange {
|
||||
source_file_edits: [
|
||||
SourceFileEdit {
|
||||
file_id: FileId(
|
||||
1,
|
||||
),
|
||||
edit: TextEdit {
|
||||
indels: [
|
||||
Indel {
|
||||
insert: "bar",
|
||||
delete: 16..19,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
file_system_edits: [
|
||||
MoveFile {
|
||||
src: FileId(
|
||||
2,
|
||||
),
|
||||
anchor: FileId(
|
||||
2,
|
||||
),
|
||||
dst: "bar.rs",
|
||||
},
|
||||
],
|
||||
is_snippet: false,
|
||||
},
|
||||
}
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_module_rename_in_path() {
|
||||
check(
|
||||
|
@ -818,7 +865,7 @@ pub mod foo<|>;
|
|||
3,
|
||||
),
|
||||
anchor: FileId(
|
||||
2,
|
||||
3,
|
||||
),
|
||||
dst: "foo2.rs",
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue