From b375886073a104b53854849ef0266314b81cb905 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sun, 17 Apr 2022 18:24:46 -0700 Subject: [PATCH] mux: spawn pane if needed when using launcher to attach If we had previously killed all the panes in a remote mux, and then reconnected to it using the launcher menu attach option, we could end up in a confusing state where we connect but don't show anything for the remote; it looks like nothing happened even though it is legitimately showing the empty remote mux. This commit checks for that case and spawns the default program in the remote if there are no panes. --- wezterm-gui/src/overlay/launcher.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/wezterm-gui/src/overlay/launcher.rs b/wezterm-gui/src/overlay/launcher.rs index fa99ca41a..86fe3ad93 100644 --- a/wezterm-gui/src/overlay/launcher.rs +++ b/wezterm-gui/src/overlay/launcher.rs @@ -620,7 +620,21 @@ fn do_domain_attach(domain: DomainId, window: WindowId) { let domain = mux .get_domain(domain) .ok_or_else(|| anyhow!("launcher attach called with unresolvable domain id!?"))?; - domain.attach(Some(window)).await + domain.attach(Some(window)).await?; + + let have_panes_in_domain = mux + .iter_panes() + .iter() + .any(|p| p.domain_id() == domain.domain_id()); + + if !have_panes_in_domain { + let config = config::configuration(); + let _tab = domain + .spawn(config.initial_size(), None, None, window) + .await?; + } + + Result::<(), anyhow::Error>::Ok(()) }) .detach(); }