diff --git a/crates/debugger_ui/src/session/running.rs b/crates/debugger_ui/src/session/running.rs index 626c807ded5e0a01b086d7311cc083bab321c7f6..59e7226f596f1266fdeb3c5f3b60e1f97b81c850 100644 --- a/crates/debugger_ui/src/session/running.rs +++ b/crates/debugger_ui/src/session/running.rs @@ -356,11 +356,11 @@ pub(crate) fn new_debugger_pane( debug_assert!(_previous_subscription.is_none()); running .panes - .split(&this_pane, &new_pane, split_direction, cx)?; - anyhow::Ok(new_pane) + .split(&this_pane, &new_pane, split_direction, cx); + new_pane }); - match new_pane.and_then(|r| r) { + match new_pane { Ok(new_pane) => { move_item( &source, diff --git a/crates/terminal_view/src/terminal_panel.rs b/crates/terminal_view/src/terminal_panel.rs index 80926f17f0ce5a4cd464bfe3bf71e5576495d407..88bde3c771f72a0771a405cfbf123ac4e2286ad9 100644 --- a/crates/terminal_view/src/terminal_panel.rs +++ b/crates/terminal_view/src/terminal_panel.rs @@ -397,10 +397,7 @@ impl TerminalPanel { }; panel .update_in(cx, |panel, window, cx| { - panel - .center - .split(&pane, &new_pane, direction, cx) - .log_err(); + panel.center.split(&pane, &new_pane, direction, cx); window.focus(&new_pane.focus_handle(cx), cx); }) .ok(); @@ -424,7 +421,7 @@ impl TerminalPanel { new_pane.update(cx, |pane, cx| { pane.add_item(item, true, true, None, window, cx); }); - self.center.split(&pane, &new_pane, direction, cx).log_err(); + self.center.split(&pane, &new_pane, direction, cx); window.focus(&new_pane.focus_handle(cx), cx); } }; @@ -1303,17 +1300,13 @@ pub fn new_terminal_pane( &new_pane, split_direction, cx, - )?; - anyhow::Ok(new_pane) + ); + new_pane }) else { return; }; - let Some(new_pane) = new_pane.log_err() else { - return; - }; - move_item( &source, &new_pane, @@ -1569,15 +1562,12 @@ impl Render for TerminalPanel { _ = terminal_panel.update_in( cx, |terminal_panel, window, cx| { - terminal_panel - .center - .split( - &terminal_panel.active_pane, - &new_pane, - SplitDirection::Right, - cx, - ) - .log_err(); + terminal_panel.center.split( + &terminal_panel.active_pane, + &new_pane, + SplitDirection::Right, + cx, + ); let new_pane = new_pane.read(cx); window.focus(&new_pane.focus_handle(cx), cx); }, diff --git a/crates/workspace/src/pane_group.rs b/crates/workspace/src/pane_group.rs index 1d28b05514baa53244926bfad906e667b0b287cd..0921a19486718c5375ed17ebbb3d7e314546f8d7 100644 --- a/crates/workspace/src/pane_group.rs +++ b/crates/workspace/src/pane_group.rs @@ -61,22 +61,33 @@ impl PaneGroup { new_pane: &Entity, direction: SplitDirection, cx: &mut App, - ) -> Result<()> { - let result = match &mut self.root { + ) { + let found = match &mut self.root { Member::Pane(pane) => { if pane == old_pane { self.root = Member::new_axis(old_pane.clone(), new_pane.clone(), direction); - Ok(()) + true } else { - anyhow::bail!("Pane not found"); + false } } Member::Axis(axis) => axis.split(old_pane, new_pane, direction), }; - if result.is_ok() { - self.mark_positions(cx); + + // If the pane wasn't found, fall back to splitting the first pane in the tree. + if !found { + let first_pane = self.root.first_pane(); + match &mut self.root { + Member::Pane(_) => { + self.root = Member::new_axis(first_pane, new_pane.clone(), direction); + } + Member::Axis(axis) => { + let _ = axis.split(&first_pane, new_pane, direction); + } + } } - result + + self.mark_positions(cx); } pub fn bounding_box_for_pane(&self, pane: &Entity) -> Option> { @@ -612,12 +623,12 @@ impl PaneAxis { old_pane: &Entity, new_pane: &Entity, direction: SplitDirection, - ) -> Result<()> { + ) -> bool { for (mut idx, member) in self.members.iter_mut().enumerate() { match member { Member::Axis(axis) => { - if axis.split(old_pane, new_pane, direction).is_ok() { - return Ok(()); + if axis.split(old_pane, new_pane, direction) { + return true; } } Member::Pane(pane) => { @@ -631,12 +642,12 @@ impl PaneAxis { *member = Member::new_axis(old_pane.clone(), new_pane.clone(), direction); } - return Ok(()); + return true; } } } } - anyhow::bail!("Pane not found"); + false } fn insert_pane(&mut self, idx: usize, new_pane: &Entity) { diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index c1d26476544ecf5db51a9c7b358ad12c84aa168f..975f00d589b76e56bcf6d819798c23bd8844a2d6 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -4275,14 +4275,7 @@ impl Workspace { .find_pane_in_direction(direction, cx) .unwrap_or_else(|| self.active_pane.clone()); let new_pane = self.add_pane(window, cx); - if self - .center - .split(&split_off_pane, &new_pane, direction, cx) - .log_err() - .is_none() - { - return; - }; + self.center.split(&split_off_pane, &new_pane, direction, cx); new_pane } }; @@ -4465,14 +4458,8 @@ impl Workspace { return; } let new_pane = self.add_pane(window, cx); - if self - .center - .split(&self.active_pane, &new_pane, action.direction, cx) - .log_err() - .is_none() - { - return; - }; + self.center + .split(&self.active_pane, &new_pane, action.direction, cx); new_pane } }; @@ -4770,8 +4757,7 @@ impl Workspace { ) -> Entity { let new_pane = self.add_pane(window, cx); self.center - .split(&pane_to_split, &new_pane, split_direction, cx) - .unwrap(); + .split(&pane_to_split, &new_pane, split_direction, cx); cx.notify(); new_pane } @@ -4790,7 +4776,7 @@ impl Workspace { new_pane.update(cx, |pane, cx| { pane.add_item(item, true, true, None, window, cx) }); - self.center.split(&pane, &new_pane, direction, cx).unwrap(); + self.center.split(&pane, &new_pane, direction, cx); cx.notify(); } @@ -4817,7 +4803,7 @@ impl Workspace { pane.set_nav_history(nav_history, cx); pane.add_item(clone, true, true, None, window, cx) }); - this.center.split(&pane, &new_pane, direction, cx).unwrap(); + this.center.split(&pane, &new_pane, direction, cx); cx.notify(); new_pane })