From 8d03885274ce9c95c9fe1a776c8743fbfc5baaee Mon Sep 17 00:00:00 2001 From: suhel Date: Thu, 30 Jul 2026 15:16:32 +0530 Subject: [PATCH] newly create pane will be focused when created --- crates/rmux-app/src/app.rs | 9 +++++++++ crates/rmux-app/src/workspace/mod.rs | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/crates/rmux-app/src/app.rs b/crates/rmux-app/src/app.rs index 03931bc..b3dedc6 100644 --- a/crates/rmux-app/src/app.rs +++ b/crates/rmux-app/src/app.rs @@ -716,6 +716,15 @@ impl RmuxApp { cwd.as_deref(), bg_opacity, ); + if let Some(terminal) = self + .workspace_manager + .active_mut() + .root + .find_pane_mut(new_id) + .and_then(|pane| pane.active_terminal_mut()) + { + terminal.set_focus(true); + } let workspace_id = self.workspace_manager.active().id.0; self.publish_event( "pane.created", diff --git a/crates/rmux-app/src/workspace/mod.rs b/crates/rmux-app/src/workspace/mod.rs index 6fb5f84..e7a492b 100644 --- a/crates/rmux-app/src/workspace/mod.rs +++ b/crates/rmux-app/src/workspace/mod.rs @@ -299,6 +299,7 @@ impl WorkspaceManager { let ws = &mut self.workspaces[index]; let active = ws.active_pane_id(); let new_id = ws.split_right(active, &mut self.next_pane_id, &mut self.next_split_id)?; + ws.active_pane = new_id; self.check_pane_guardrail(); Ok(new_id) } @@ -311,6 +312,7 @@ impl WorkspaceManager { let ws = &mut self.workspaces[index]; let active = ws.active_pane_id(); let new_id = ws.split_down(active, &mut self.next_pane_id, &mut self.next_split_id)?; + ws.active_pane = new_id; self.check_pane_guardrail(); Ok(new_id) } @@ -787,6 +789,7 @@ mod tests { let new_id = manager.split_active_right().unwrap(); assert_eq!(manager.total_pane_count(), 2); assert!(new_id.0 > 0); + assert_eq!(manager.active().active_pane, new_id); } #[test] @@ -797,6 +800,7 @@ mod tests { let new_id = manager.split_active_down().unwrap(); assert_eq!(manager.total_pane_count(), 2); assert!(new_id.0 > 0); + assert_eq!(manager.active().active_pane, new_id); } #[test] @@ -1095,6 +1099,7 @@ mod tests { let mut manager = WorkspaceManager::new(); let original_pane = manager.active().active_pane; manager.split_active_right().expect("split ok"); + manager.focus_pane_global(original_pane); manager.new_surface_in_active(None).unwrap(); manager.new_surface_in_active(None).unwrap(); manager.close_surface_in_active_with_capture(None).expect("close should succeed");