From a71bfd41cc8af42f8e80276084210bb9baf9d074 Mon Sep 17 00:00:00 2001 From: CharlesChen0823 Date: Thu, 8 Aug 2024 21:58:59 +0800 Subject: [PATCH] recent_project: Fix overflow sub (#15965) close: #15783 Release Notes: - Fixed a potential panic that can occur when deleting entries from the recent-projects menu ([#15783](https://github.com/zed-industries/zed/issues/15783)) --- crates/recent_projects/src/recent_projects.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/recent_projects/src/recent_projects.rs b/crates/recent_projects/src/recent_projects.rs index 7b75c280d6..fcb6ffef42 100644 --- a/crates/recent_projects/src/recent_projects.rs +++ b/crates/recent_projects/src/recent_projects.rs @@ -669,7 +669,7 @@ impl RecentProjectsDelegate { .unwrap_or_default(); this.update(&mut cx, move |picker, cx| { picker.delegate.set_workspaces(workspaces); - picker.delegate.set_selected_index(ix - 1, cx); + picker.delegate.set_selected_index(ix.saturating_sub(1), cx); picker.delegate.reset_selected_match_index = false; picker.update_matches(picker.query(cx), cx) })