diff options
Diffstat (limited to 'src/workspace.rs')
| -rw-r--r-- | src/workspace.rs | 100 |
1 files changed, 39 insertions, 61 deletions
diff --git a/src/workspace.rs b/src/workspace.rs index 0d0e35bd..bfda45f6 100644 --- a/src/workspace.rs +++ b/src/workspace.rs @@ -891,70 +891,40 @@ impl Workspace { let tab_number = self.tabs[tab_idx].number; let launch_env = self.launch_env_for_new_pane(tab_number, pane_number, extra_env); let tab = &mut self.tabs[tab_idx]; - let previous_focus = tab.layout.focused(); - tab.layout.focus_pane(pane_id); let new_pane = match if let Some(argv) = argv { - match ratio { - Some(ratio) => tab.split_focused_argv_command_with_ratio( - direction, - ratio, - rows, - cols, - cwd, - argv, - &launch_env, - scrollback_limit_bytes, - host_terminal_theme, - host_terminal_appearance, - ), - None => tab.split_focused_argv_command( - direction, - rows, - cols, - cwd, - argv, - &launch_env, - scrollback_limit_bytes, - host_terminal_theme, - host_terminal_appearance, - ), - } + tab.split_pane_argv( + pane_id, + focus_new_pane, + direction, + ratio, + rows, + cols, + cwd, + argv, + &launch_env, + scrollback_limit_bytes, + host_terminal_theme, + host_terminal_appearance, + ) } else { - match ratio { - Some(ratio) => tab.split_focused_with_ratio( - direction, - ratio, - rows, - cols, - cwd, - scrollback_limit_bytes, - host_terminal_theme, - host_terminal_appearance, - shell_config, - &launch_env, - ), - None => tab.split_focused( - direction, - rows, - cols, - cwd, - scrollback_limit_bytes, - host_terminal_theme, - host_terminal_appearance, - shell_config, - &launch_env, - ), - } + tab.split_pane_shell( + pane_id, + focus_new_pane, + direction, + ratio, + rows, + cols, + cwd, + scrollback_limit_bytes, + host_terminal_theme, + host_terminal_appearance, + shell_config, + &launch_env, + ) } { Ok(new_pane) => new_pane, - Err(err) => { - tab.layout.focus_pane(previous_focus); - return Some(Err(err)); - } + Err(err) => return Some(Err(err)), }; - if !focus_new_pane { - tab.layout.focus_pane(previous_focus); - } self.register_new_pane_with_number(new_pane.pane_id, pane_number); Some(Ok((tab_idx, new_pane))) } @@ -1034,12 +1004,13 @@ impl Workspace { moved: MovedPane, direction: Direction, ratio: f32, + focus: bool, ) -> Result<PaneId, MovedPane> { let pane_id = moved.pane_id; let Some(tab) = self.tabs.get_mut(tab_idx) else { return Err(moved); }; - tab.insert_existing_pane(target_pane_id, moved, direction, ratio)?; + tab.insert_existing_pane(target_pane_id, moved, direction, ratio, focus)?; if !self.public_pane_numbers.contains_key(&pane_id) { self.register_new_pane_with_number(pane_id, self.next_public_pane_number); } @@ -1665,7 +1636,14 @@ mod tests { let missing_target = PaneId::alloc(); let recovered = target - .insert_moved_pane_into_tab(0, missing_target, taken.moved, Direction::Horizontal, 0.5) + .insert_moved_pane_into_tab( + 0, + missing_target, + taken.moved, + Direction::Horizontal, + 0.5, + true, + ) .expect_err("invalid target should return the moved pane"); assert_eq!(recovered.pane_id, source_pane); |
