From 3984cc6d39996eb3fa1b8c9a6f35f4930e2356cf Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Fri, 19 May 2023 12:37:36 +0300 Subject: [PATCH] Properly handle WorktreeId --- crates/file_finder/src/file_finder.rs | 6 +++--- crates/project/src/worktree.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/file_finder/src/file_finder.rs b/crates/file_finder/src/file_finder.rs index 8ba58819a3..5270b694b2 100644 --- a/crates/file_finder/src/file_finder.rs +++ b/crates/file_finder/src/file_finder.rs @@ -265,7 +265,7 @@ impl PickerDelegate for FileFinderDelegate { .map(|(i, history_item)| PathMatch { score: i as f64, positions: Vec::new(), - worktree_id: history_item.worktree_id.0, + worktree_id: history_item.worktree_id.to_usize(), path: Arc::clone(&history_item.path), path_prefix: "".into(), distance_to_relative_ancestor: usize::MAX, @@ -870,7 +870,7 @@ mod tests { let worktree_id = cx.read(|cx| { let worktrees = workspace.read(cx).worktrees(cx).collect::>(); assert_eq!(worktrees.len(), 1); - WorktreeId(worktrees[0].id()) + WorktreeId::from_usize(worktrees[0].id()) }); // When workspace has an active item, sort items which are closer to that item @@ -975,7 +975,7 @@ mod tests { let worktree_id = cx.read(|cx| { let worktrees = workspace.read(cx).worktrees(cx).collect::>(); assert_eq!(worktrees.len(), 1); - WorktreeId(worktrees[0].id()) + WorktreeId::from_usize(worktrees[0].id()) }); // Open and close panels, getting their history items afterwards. diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index 550a27ea9f..403d893425 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -58,7 +58,7 @@ use sum_tree::{Bias, Edit, SeekTarget, SumTree, TreeMap, TreeSet}; use util::{paths::HOME, ResultExt, TakeUntilExt, TryFutureExt}; #[derive(Copy, Clone, PartialEq, Eq, Debug, Hash, PartialOrd, Ord)] -pub struct WorktreeId(pub usize); +pub struct WorktreeId(usize); pub enum Worktree { Local(LocalWorktree),