Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Remove panic in recent projects picker

Mikayla Maki097a768725ab
diff --git a/crates/recent_projects/src/recent_projects.rs b/crates/recent_projects/src/recent_projects.rs
index f613ba4df21..e73d0b4fb51 100644
--- a/crates/recent_projects/src/recent_projects.rs
+++ b/crates/recent_projects/src/recent_projects.rs
@@ -165,12 +165,13 @@ impl PickerDelegate for RecentProjectsView {
}
fn confirm(&mut self, cx: &mut ViewContext<Self>) {
- let selected_match = &self.matches[self.selected_index()];
- let workspace_location = &self.workspace_locations[selected_match.candidate_id];
- cx.dispatch_global_action(OpenPaths {
- paths: workspace_location.paths().as_ref().clone(),
- });
- cx.emit(Event::Dismissed);
+ if let Some(selected_match) = &self.matches.get(self.selected_index()) {
+ let workspace_location = &self.workspace_locations[selected_match.candidate_id];
+ cx.dispatch_global_action(OpenPaths {
+ paths: workspace_location.paths().as_ref().clone(),
+ });
+ cx.emit(Event::Dismissed);
+ }
}
fn dismiss(&mut self, cx: &mut ViewContext<Self>) {