diff options
author | Emil Fresk | 2022-03-08 18:51:19 +0000 |
---|---|---|
committer | GitHub | 2022-03-08 18:51:19 +0000 |
commit | bfa533fe78a439da6d96e6ba94bdb4c6d7c4a3b3 (patch) | |
tree | a14cd31fd6cc7b6b507747f02c87801945b78203 | |
parent | 194b09fbc1edb2d0ccdadc53ec0893f61dbded8e (diff) |
Fix bug in LSP when creating a file in a folder that does not exist (#1775)
-rw-r--r-- | helix-term/src/commands/lsp.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs index aa7fa1c8..308ff829 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, []) } } |