Skip to content

Commit 98c3131

Browse files
committed
Fix LSP crash on delete file - didn't delete properly
1 parent 2087402 commit 98c3131

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/dev_aid/lsp/mod.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -574,16 +574,20 @@ fn handle_notification(
574574
}
575575
}
576576
// Delete files that no longer exist. We have to do it like this because the path received from a deletion event is already deleted, and it could be through several symlinks, so we couldn't use it for identity matching.
577-
linker.files.retain(|_, v| {
578-
if v.file_identifier.inode.is_some() {
579-
match std::fs::exists(&v.file_identifier.name) {
580-
Ok(true) => true,
581-
Ok(false) | Err(_) => false,
577+
let mut to_delete: Vec<FileUUID> = Vec::new();
578+
for (id, f) in &linker.files {
579+
if f.file_identifier.inode.is_some() {
580+
match std::fs::exists(&f.file_identifier.name) {
581+
Ok(true) => {}
582+
Ok(false) | Err(_) => to_delete.push(id),
582583
}
583584
} else {
584-
true // String-based inodes are not file backed
585+
// String-based inodes are not file backed
585586
}
586-
});
587+
}
588+
for f_id in to_delete {
589+
linker.remove_file(f_id);
590+
}
587591

588592
true
589593
}

0 commit comments

Comments
 (0)