This commit is contained in:
Pontus Laestadius 2024-11-21 17:51:50 -05:00 committed by GitHub
commit d65c8991e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1390,6 +1390,10 @@ pub fn move_path(&mut self, old_path: &Path, new_path: &Path) -> io::Result<()>
log::error!("failed to apply workspace edit: {err:?}")
}
}
// Create the target directory if it doesn't exist. fs::rename won't do that implicitly.
if let Some(parent) = new_path.parent() {
fs::create_dir_all(parent)?;
}
fs::rename(old_path, &new_path)?;
if let Some(doc) = self.document_by_path(old_path) {
self.set_doc_path(doc.id(), &new_path);