From 8445b4adfbbd3b32d0d0e24504c111ca17e397c7 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Fri, 11 Oct 2024 15:38:12 +0300 Subject: [PATCH] Properly compute depth and path for project panel entries (#19068) Closes https://github.com/zed-industries/zed/issues/18939 This fixes incorrect width estimates and horizontal scrollbar glitches Release Notes: - Fixes horizontal scrollbar not scrolling enough for certain paths ([#18939](https://github.com/zed-industries/zed/issues/18939)) Co-authored-by: Piotr Osiewicz --- crates/project_panel/src/project_panel.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index 53b274ee6fa96428ee4c8373b944497d7a2107c1..1e6f1e5a17dbcbf004ff5288839b5c152d9be7a0 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -1906,11 +1906,9 @@ impl ProjectPanel { Some(Arc::::from(full_path.join(suffix))) }) }) + .or_else(|| entry.path.file_name().map(Path::new).map(Arc::from)) .unwrap_or_else(|| entry.path.clone()); - let depth = path - .strip_prefix(worktree_abs_path) - .map(|suffix| suffix.components().count()) - .unwrap_or_default(); + let depth = path.components().count(); (depth, path) }; let width_estimate = item_width_estimate(