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))
This commit is contained in:
CharlesChen0823 2024-08-08 21:58:59 +08:00 committed by GitHub
parent 73fb8277fc
commit a71bfd41cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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