From bb0dad86f81768c8b7d5894acf7cd53bd05d302b Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Fri, 8 May 2026 15:37:01 +0300 Subject: fix: split panes in target tab without stealing focus fixes #75 --- src/workspace.rs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/workspace.rs') diff --git a/src/workspace.rs b/src/workspace.rs index e429ec10..f9fb0493 100644 --- a/src/workspace.rs +++ b/src/workspace.rs @@ -244,6 +244,42 @@ impl Workspace { Ok(new_id) } + pub fn split_pane( + &mut self, + pane_id: PaneId, + direction: Direction, + rows: u16, + cols: u16, + cwd: Option, + scrollback_limit_bytes: usize, + host_terminal_theme: crate::terminal_theme::TerminalTheme, + focus_new_pane: bool, + ) -> Option> { + let tab_idx = self.find_tab_index_for_pane(pane_id)?; + let tab = &mut self.tabs[tab_idx]; + let previous_focus = tab.layout.focused(); + tab.layout.focus_pane(pane_id); + let new_id = match tab.split_focused( + direction, + rows, + cols, + cwd, + scrollback_limit_bytes, + host_terminal_theme, + ) { + Ok(new_id) => new_id, + Err(err) => { + tab.layout.focus_pane(previous_focus); + return Some(Err(err)); + } + }; + if !focus_new_pane { + tab.layout.focus_pane(previous_focus); + } + self.register_new_pane(new_id); + Some(Ok((tab_idx, new_id))) + } + /// Close the focused pane. Returns true if the workspace should close. pub fn close_focused(&mut self) -> bool { let pane_count = self -- cgit v1.2.3