diff --git a/crates/sidebar/src/sidebar.rs b/crates/sidebar/src/sidebar.rs index da46e604e79942a285427ca3961287f1a285fcd1..a1407a978f6f85810d52a40ef71b546e5f977209 100644 --- a/crates/sidebar/src/sidebar.rs +++ b/crates/sidebar/src/sidebar.rs @@ -25,7 +25,7 @@ use ui::utils::platform_title_bar_height; use settings::Settings as _; use std::collections::{HashMap, HashSet}; use std::mem; -use std::path::Path; +use std::path::{Path, PathBuf}; use std::rc::Rc; use std::sync::Arc; use theme::ActiveTheme; @@ -190,7 +190,7 @@ fn root_repository_snapshots( workspace: &Entity, cx: &App, ) -> Vec { - let path_list = workspace_path_list(workspace, cx); + let path_list = workspace.read(cx).path_list(cx); let project = workspace.read(cx).project().read(cx); project .repositories(cx) @@ -206,12 +206,6 @@ fn root_repository_snapshots( .collect() } -fn workspace_path_list(workspace: &Entity, cx: &App) -> PathList { - PathList::new(&workspace.read(cx).root_paths(cx)) -} - -use std::path::PathBuf; - /// Build a mapping from git worktree checkout paths to their root repo paths. /// /// For each open workspace's repositories, registers both the main repo path @@ -839,7 +833,7 @@ impl Sidebar { let has_open_projects = workspaces .iter() - .any(|ws| !workspace_path_list(ws, cx).paths().is_empty()); + .any(|ws| !ws.read(cx).path_list(cx).paths().is_empty()); let active_ws_index = active_workspace .as_ref() @@ -855,7 +849,7 @@ impl Sidebar { continue; } - let path_list = workspace_path_list(workspace, cx); + let path_list = workspace.read(cx).path_list(cx); if path_list.paths().is_empty() { continue; } @@ -2047,7 +2041,7 @@ impl Sidebar { // contains other folders. let mut to_remove: Vec> = Vec::new(); for workspace in &workspaces { - let path_list = workspace_path_list(workspace, cx); + let path_list = workspace.read(cx).path_list(cx); if path_list.paths().len() != 1 { continue; } @@ -2488,7 +2482,7 @@ impl Sidebar { let worktree_to_root = build_worktree_root_mapping(&[workspace.clone()], cx); let canonical_thread = canonicalize_path_list(path_list, &worktree_to_root); let canonical_workspace = - canonicalize_path_list(&workspace_path_list(workspace, cx), &worktree_to_root); + canonicalize_path_list(&workspace.read(cx).path_list(cx), &worktree_to_root); canonical_workspace == canonical_thread }) } @@ -2502,7 +2496,7 @@ impl Sidebar { let worktree_to_root = build_worktree_root_mapping(&[workspace.clone()], cx); let canonical_thread = canonicalize_path_list(path_list, &worktree_to_root); let canonical_workspace = - canonicalize_path_list(&workspace_path_list(workspace, cx), &worktree_to_root); + canonicalize_path_list(&workspace.read(cx).path_list(cx), &worktree_to_root); canonical_workspace == canonical_thread }) } @@ -6464,8 +6458,7 @@ mod tests { mw.workspaces()[1].clone() }); - let new_path_list = - new_workspace.read_with(cx, |_, cx| workspace_path_list(&new_workspace, cx)); + let new_path_list = new_workspace.read_with(cx, |ws, cx| ws.path_list(cx)); assert_eq!( new_path_list, PathList::new(&[std::path::PathBuf::from("/wt-feature-a")]), diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 0acc15697008d427efbe0371040a88945b8694c1..9b803d847b64151aaf819f8407f521bae7e1b05c 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -6115,6 +6115,10 @@ impl Workspace { .collect::>() } + pub fn path_list(&self, cx: &App) -> PathList { + PathList::new(&self.root_paths(cx)) + } + fn remove_panes(&mut self, member: Member, window: &mut Window, cx: &mut Context) { match member { Member::Axis(PaneAxis { members, .. }) => {