Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Fix panic in file finder path elision (#25658)

Cole Miller6d17546b1aa4
diff --git a/crates/file_finder/src/file_finder.rs b/crates/file_finder/src/file_finder.rs
index 984cf953f66..7d537e5cb7f 100644
--- a/crates/file_finder/src/file_finder.rs
+++ b/crates/file_finder/src/file_finder.rs
@@ -909,7 +909,9 @@ impl FileFinderDelegate {
(normal, small)
};
let budget = full_path_budget(&file_name, normal_em, small_em, max_width);
- if full_path.len() > budget {
+ // If the computed budget is zero, we certainly won't be able to achieve it,
+ // so no point trying to elide the path.
+ if budget > 0 && full_path.len() > budget {
let components = PathComponentSlice::new(&full_path);
if let Some(elided_range) =
components.elision_range(budget - 1, &full_path_positions)