Anchor file-system operations to the file, and not to the source root.
Anchoring to the SourceRoot wont' work if the path is absolute: #[path = "/tmp/foo.rs"] mod foo; Anchoring to a file will. However, we *should* anchor, instead of just producing an abs path. I can imagine a situation where, for example, rust-analyzer processes crates from different machines (or, for example, from in-memory git branch), where the same absolute path in different crates might refer to different files in the end!
This commit is contained in:
@@ -528,13 +528,13 @@ pub(crate) fn resource_op(
|
||||
file_system_edit: FileSystemEdit,
|
||||
) -> lsp_types::ResourceOp {
|
||||
match file_system_edit {
|
||||
FileSystemEdit::CreateFile { source_root, path } => {
|
||||
let uri = snap.path_to_url(source_root, &path);
|
||||
FileSystemEdit::CreateFile { anchor, dst } => {
|
||||
let uri = snap.anchored_path(anchor, &dst);
|
||||
lsp_types::ResourceOp::Create(lsp_types::CreateFile { uri, options: None })
|
||||
}
|
||||
FileSystemEdit::MoveFile { src, dst_source_root, dst_path } => {
|
||||
FileSystemEdit::MoveFile { src, anchor, dst } => {
|
||||
let old_uri = snap.file_id_to_url(src);
|
||||
let new_uri = snap.path_to_url(dst_source_root, &dst_path);
|
||||
let new_uri = snap.anchored_path(anchor, &dst);
|
||||
lsp_types::ResourceOp::Rename(lsp_types::RenameFile { old_uri, new_uri, options: None })
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user