diff --git a/crates/filesystem/src/path_cache.rs b/crates/filesystem/src/path_cache.rs index a5708874..5fb661a4 100644 --- a/crates/filesystem/src/path_cache.rs +++ b/crates/filesystem/src/path_cache.rs @@ -465,8 +465,13 @@ where self.fs.remove_dir(&path).wrap_err_with(|| c.clone())?; + // Remove the directory and its contents from `cache.trie` and `cache.cactus` { let cache = &mut *cache; + + let mut path = to_lowercase(path); + path.set_extension(""); + for extension_trie in cache.trie.iter_prefix(&path).unwrap().map(|(_, t)| t) { for index in extension_trie.values().copied() { cache.cactus.remove(index); @@ -490,14 +495,19 @@ where self.fs.remove_file(&path).wrap_err_with(|| c.clone())?; + // Remove the file from `cache.trie` and `cache.cactus` { let cache = &mut *cache; - for extension_trie in cache.trie.iter_prefix(&path).unwrap().map(|(_, t)| t) { - for index in extension_trie.values().copied() { - cache.cactus.remove(index); - } + + let mut path = to_lowercase(path); + path.set_extension(""); + let path = with_trie_suffix(&path); + + let extension_trie = cache.trie.get_file(&path).unwrap(); + for index in extension_trie.values().copied() { + cache.cactus.remove(index); } - cache.trie.remove_dir(&path); + cache.trie.remove_file(&path); } Ok(())