From 92920ebf5d843cbb6f50c64fdd7df9adf352f0d2 Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Mon, 23 Mar 2026 14:04:04 -0700 Subject: [PATCH] Remove redundant worktree mapping loop from rebuild_contents MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This loop was a leftover from when build_worktree_root_mapping only iterated root_repository_snapshots. Now that it iterates all repos from all workspaces, it already inserts work_directory → root mappings for every repo, making this extra loop redundant. --- crates/sidebar/src/sidebar.rs | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/crates/sidebar/src/sidebar.rs b/crates/sidebar/src/sidebar.rs index a1407a978f6f85810d52a40ef71b546e5f977209..c8c045699e9bfd1b915b0c62ddbadf494ebaba4d 100644 --- a/crates/sidebar/src/sidebar.rs +++ b/crates/sidebar/src/sidebar.rs @@ -684,8 +684,9 @@ impl Sidebar { } } - /// When modifying this thread, aim for a single forward pass over workspaces - /// and threads plus an O(T log T) sort. Avoid adding extra scans over the data. + /// When modifying this thread, aim for a single forward pass over + /// workspaces and threads plus an O(T log T) sort, where T is the number of + /// threads. Avoid adding extra scans over the data. fn rebuild_contents(&mut self, cx: &App) { let Some(multi_workspace) = self.multi_workspace.upgrade() else { return; @@ -797,26 +798,7 @@ impl Sidebar { // Build a mapping from worktree checkout paths → root repo paths so // that threads saved against a worktree checkout can be grouped under // the root repo's sidebar header. - let mut worktree_to_root = build_worktree_root_mapping(&workspaces, cx); - - // Also add mappings discovered during absorption detection. - // These are robust against snapshot timing because they come - // from each worktree workspace's own repo snapshot (which - // always knows its own work_directory and original_repo), - // even when the main repo's linked-worktree list is - // temporarily incomplete. - for workspace in &workspaces { - let project = workspace.read(cx).project().read(cx); - for repo in project.repositories(cx).values() { - let snapshot = repo.read(cx).snapshot(); - if snapshot.work_directory_abs_path != snapshot.original_repo_abs_path { - worktree_to_root.insert( - snapshot.work_directory_abs_path.to_path_buf(), - snapshot.original_repo_abs_path.clone(), - ); - } - } - } + let worktree_to_root = build_worktree_root_mapping(&workspaces, cx); // Build a canonicalized thread index: for each thread in the store, // map its folder_paths to root repo paths and index by the result.