Skip to content

Commit

Permalink
Avoid unwrap in file finder (#18374)
Browse files Browse the repository at this point in the history
Release Notes:

- Fixed a (rare) panic in file finder

---------

Co-authored-by: Kirill Bulatov <[email protected]>
  • Loading branch information
ConradIrwin and SomeoneToIgnore committed Sep 27, 2024
1 parent 25e2e9c commit 8b57259
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions crates/file_finder/src/file_finder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ fn matching_history_items<'a>(
.chars(),
),
};
candidates_paths.insert(Arc::clone(&found_path.project.path), found_path);
candidates_paths.insert(&found_path.project, found_path);
Some((found_path.project.worktree_id, candidate))
})
.fold(
Expand All @@ -411,17 +411,21 @@ fn matching_history_items<'a>(
max_results,
)
.into_iter()
.map(|path_match| {
let (_, found_path) = candidates_paths
.remove_entry(&path_match.path)
.expect("candidate info not found");
(
Arc::clone(&path_match.path),
Match::History {
path: found_path.clone(),
panel_match: Some(ProjectPanelOrdMatch(path_match)),
},
)
.filter_map(|path_match| {
candidates_paths
.remove_entry(&ProjectPath {
worktree_id: WorktreeId::from_usize(path_match.worktree_id),
path: Arc::clone(&path_match.path),
})
.map(|(_, found_path)| {
(
Arc::clone(&path_match.path),
Match::History {
path: found_path.clone(),
panel_match: Some(ProjectPanelOrdMatch(path_match)),
},
)
})
}),
);
}
Expand Down

0 comments on commit 8b57259

Please sign in to comment.