From c193b0b8fc03abf8ff31982fe81c7cec73e25f51 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Fri, 19 May 2023 15:10:29 -0700 Subject: [PATCH] Add guards to other pane index removals --- crates/workspace/src/pane.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index 39f1a9fd9e..a196133f3a 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -711,10 +711,7 @@ impl Pane { let pane_handle = workspace.active_pane().clone(); let pane = pane_handle.read(cx); - if pane.items.is_empty() { - return None; - } - let active_item_id = pane.items[pane.active_item_index].id(); + let active_item_id = pane.items.get(pane.active_item_index)?.id(); let task = Self::close_item_by_id(workspace, pane_handle, active_item_id, cx); @@ -742,7 +739,8 @@ impl Pane { ) -> Option>> { let pane_handle = workspace.active_pane().clone(); let pane = pane_handle.read(cx); - let active_item_id = pane.items[pane.active_item_index].id(); + + let active_item_id = pane.items.get(pane.active_item_index)?.id(); let task = Self::close_items(workspace, pane_handle, cx, move |item_id| { item_id != active_item_id @@ -785,7 +783,7 @@ impl Pane { ) -> Option>> { let pane_handle = workspace.active_pane().clone(); let pane = pane_handle.read(cx); - let active_item_id = pane.items[pane.active_item_index].id(); + let active_item_id = pane.items.get(pane.active_item_index)?.id(); let task = Self::close_items_to_the_left_by_id(workspace, pane_handle, active_item_id, cx); @@ -825,7 +823,7 @@ impl Pane { ) -> Option>> { let pane_handle = workspace.active_pane().clone(); let pane = pane_handle.read(cx); - let active_item_id = pane.items[pane.active_item_index].id(); + let active_item_id = pane.items.get(pane.active_item_index)?.id(); let task = Self::close_items_to_the_right_by_id(workspace, pane_handle, active_item_id, cx);