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

This commit is contained in:
Emil Fresk 2022-03-08 19:51:19 +01:00 committed by GitHub
parent 194b09fbc1
commit bfa533fe78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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, [])
}
}