From bfa533fe78a439da6d96e6ba94bdb4c6d7c4a3b3 Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Tue, 8 Mar 2022 19:51:19 +0100 Subject: [PATCH] Fix bug in LSP when creating a file in a folder that does not exist (#1775) --- helix-term/src/commands/lsp.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs index aa7fa1c87..308ff8292 100644 --- a/helix-term/src/commands/lsp.rs +++ b/helix-term/src/commands/lsp.rs @@ -286,6 +286,13 @@ pub fn apply_document_resource_op(op: &lsp::ResourceOp) -> std::io::Result<()> { if ignore_if_exists && path.exists() { Ok(()) } else { + // Create directory if it does not exist + if let Some(dir) = path.parent() { + if !dir.is_dir() { + fs::create_dir_all(&dir)?; + } + } + fs::write(&path, []) } }