on master help sign in
Fix bug in LSP when creating a file in a folder that does not exist (#1775)
commitbfa533fe78a439da6d96e6ba94bdb4c6d7c4a3b3 authorEmil Fresk <emil.fresk@gmail.com> dateTue 8 Mar 2022, 19:51 (5 years ago) parent194b09f
1 file changed+7
helix-term/src/commands/lsp.rs+7
helix-term/src/commands/lsp.rs+7
@@ -286,6 +286,13 @@ pub fn apply_document_resource_op(op: &lsp::ResourceOp) -> std::io::Result<()> {
286286 if ignore_if_exists && path.exists() {
287287 Ok(())
288288 } else {
289+ // Create directory if it does not exist
290+ if let Some(dir) = path.parent() {
291+ if !dir.is_dir() {
292+ fs::create_dir_all(&dir)?;
293+ }
294+ }
295+
289296 fs::write(&path, [])
290297 }
291298 }