Properly handle WorktreeId

This commit is contained in:
Kirill Bulatov 2023-05-19 12:37:36 +03:00
parent 34b0d6200f
commit 3984cc6d39
2 changed files with 4 additions and 4 deletions

View File

@ -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::<Vec<_>>();
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::<Vec<_>>();
assert_eq!(worktrees.len(), 1);
WorktreeId(worktrees[0].id())
WorktreeId::from_usize(worktrees[0].id())
});
// Open and close panels, getting their history items afterwards.

View File

@ -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),