Fix bug in LSP when creating a file in a folder that does not exist (#1775)

pull/1776/head
Emil Fresk 3 years ago committed by GitHub
parent 194b09fbc1
commit bfa533fe78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -286,6 +286,13 @@ pub fn apply_document_resource_op(op: &lsp::ResourceOp) -> std::io::Result<()> {
if ignore_if_exists && path.exists() { if ignore_if_exists && path.exists() {
Ok(()) Ok(())
} else { } 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, []) fs::write(&path, [])
} }
} }

Loading…
Cancel
Save