summaryrefslogtreecommitdiff
path: root/helix-term/src/commands
diff options
context:
space:
mode:
authorEmil Fresk2022-03-08 18:51:19 +0000
committerGitHub2022-03-08 18:51:19 +0000
commitbfa533fe78a439da6d96e6ba94bdb4c6d7c4a3b3 (patch)
treea14cd31fd6cc7b6b507747f02c87801945b78203 /helix-term/src/commands
parent194b09fbc1edb2d0ccdadc53ec0893f61dbded8e (diff)
Fix bug in LSP when creating a file in a folder that does not exist (#1775)
Diffstat (limited to 'helix-term/src/commands')
-rw-r--r--helix-term/src/commands/lsp.rs7
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, [])
}
}