on master help sign in
Fix bug in LSP when creating a file in a folder that does not exist (#1775)
bfa533fEmil Fresk
helix-term/src/commands/lsp.rs+7
@@ -286,6 +286,13 @@ pub fn apply_document_resource_op(op: &lsp::ResourceOp) -> std::io::Result<()> {
286 if ignore_if_exists && path.exists() {
286 if ignore_if_exists && path.exists() {
287 Ok(())
287 Ok(())
288 } else {
288 } 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+
289 fs::write(&path, [])
296 fs::write(&path, [])
290 }
297 }
291 }
298 }