From 082791211e95674f0ace3b1573271af930eb8ac0 Mon Sep 17 00:00:00 2001 From: Pontus Laestadius Date: Wed, 28 Aug 2024 18:10:42 +0200 Subject: [PATCH] helix-view:move_path create target directory on move --- helix-view/src/editor.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 1708b3b4e..0c6fa1f70 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -1370,6 +1370,10 @@ impl Editor { 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);