Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
fix infinite loop in path distance for fuzzy finder
Kay Simmonsb3dffeaf2a19
diff --git a/crates/fuzzy/src/paths.rs b/crates/fuzzy/src/paths.rsindex 2c5ce81b1cc..a5ad46b5e7e 100644--- a/crates/fuzzy/src/paths.rs+++ b/crates/fuzzy/src/paths.rs@@ -198,6 +198,25 @@ fn distance_between_paths(path: &Path, relative_to: &Path) -> usize {let mut path_components = path.components();let mut relative_components = relative_to.components();- while path_components.next() == relative_components.next() {}+ // while path_components.next() == relative_components.next() {}++ while path_components+ .next()+ .zip(relative_components.next())+ .map(|(path_component, relative_component)| path_component == relative_component)+ .unwrap_or_default()+ {}path_components.count() + relative_components.count() + 1}++#[cfg(test)]+mod tests {+ use std::path::Path;++ use super::distance_between_paths;++ #[test]+ fn test_distance_between_paths_empty() {+ distance_between_paths(Path::new(""), Path::new(""));+ }+}