mux: implicitly attach the domain referenced in a SpawnCommand

refs: https://github.com/wez/wezterm/issues/1874
This commit is contained in:
Wez Furlong committed 2022-04-17 23:02:39 -07:00
1 parent 8dfee33ef4
commit 66e8ec1586
2 files changed
+10 -4

No files matched your search

+1
View File
@@ -17,6 +17,7 @@ As features stabilize some brief notes about them will accumulate here.
* You may now use `CTRL-n` and `CTRL-p` (in addition to the up/down arrow and vi motion keys) to change the selected row in the Launcher. Thanks to [@Junnplus](https://github.com/Junnplus)! [#1880](https://github.com/wez/wezterm/pull/1880)
* Attaching multiplexer domains now attaches the first window as a tab in the active window, rather than opening a new window. [#1874](https://github.com/wez/wezterm/issues/1874)
* [AttachDomain](config/lua/keyassignment/AttachDomain.md) and [DetachDomain](config/lua/keyassignment/DetachDomain.md) key assignments
* Specifying a domain name in a [SpawnCommand](config/lua/SpawnCommand.md) will cause that domain to be attached if it is in the detached state. This is useful when combined with [SwitchToWorkspace](config/lua/keyassignment/SwitchToWorkspace.md).
#### Changed
* Debian packages now register wezterm as an alternative for `x-terminal-emulator`. Thanks to [@xpufx](https://github.com/xpufx)! [#1883](https://github.com/wez/wezterm/pull/1883)
+9 -4
View File
@@ -903,9 +903,6 @@ impl Mux {
.get_domain_by_name(&name)
.ok_or_else(|| anyhow!("domain name {} is invalid", name))?,
};
if domain.state() == DomainState::Detached {
anyhow::bail!("Cannot spawn a tab into a Detached domain");
}
Ok(domain)
}
@@ -949,7 +946,7 @@ impl Mux {
command_dir: Option<String>,
domain: config::keyassignment::SpawnTabDomain,
) -> anyhow::Result<(Rc<dyn Pane>, PtySize)> {
let (_pane_domain_id, _window_id, tab_id) = self
let (_pane_domain_id, window_id, tab_id) = self
.resolve_pane_id(pane_id)
.ok_or_else(|| anyhow!("pane_id {} invalid", pane_id))?;
@@ -957,6 +954,10 @@ impl Mux {
.resolve_spawn_tab_domain(Some(pane_id), &domain)
.context("resolve_spawn_tab_domain")?;
if domain.state() == DomainState::Detached {
domain.attach(Some(window_id)).await?;
}
let current_pane = self
.get_pane(pane_id)
.ok_or_else(|| anyhow!("pane_id {} is invalid", pane_id))?;
@@ -1023,6 +1024,10 @@ impl Mux {
(*window_builder, size)
};
if domain.state() == DomainState::Detached {
domain.attach(Some(window_id)).await?;
}
let cwd = self.resolve_cwd(
command_dir,
match current_pane_id {