From fe0bcd14d2f63111ebec7143fa6f13ae6719411a Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 27 May 2025 02:24:53 +0300 Subject: [PATCH] Activate last item if item's number is greater than the last one's (#31471) Release Notes: - N/A --- crates/workspace/src/pane.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index ad3eff848a..948ef02464 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -3249,12 +3249,18 @@ impl Render for Pane { .on_action(cx.listener(Pane::toggle_zoom)) .on_action( cx.listener(|pane: &mut Pane, action: &ActivateItem, window, cx| { - pane.activate_item(action.0, true, true, window, cx); + pane.activate_item( + action.0.min(pane.items.len().saturating_sub(1)), + true, + true, + window, + cx, + ); }), ) .on_action( cx.listener(|pane: &mut Pane, _: &ActivateLastItem, window, cx| { - pane.activate_item(pane.items.len() - 1, true, true, window, cx); + pane.activate_item(pane.items.len().saturating_sub(1), true, true, window, cx); }), ) .on_action(