From 0899282ea6af8ae2a215d1d25b1e60161e7134cb Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Fri, 8 Jul 2022 20:36:40 -0700 Subject: [PATCH] exec_domains: soft-bind to the config definition This allows config file changes to be reflected --- mux/src/domain.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/mux/src/domain.rs b/mux/src/domain.rs index 52109205a..2819d58c6 100644 --- a/mux/src/domain.rs +++ b/mux/src/domain.rs @@ -175,7 +175,6 @@ pub struct LocalDomain { id: DomainId, name: String, wsl: Option, - exec_domain: Option, } impl LocalDomain { @@ -183,6 +182,14 @@ impl LocalDomain { Ok(Self::with_pty_system(name, native_pty_system())) } + fn resolve_exec_domain(&self) -> Option { + config::configuration() + .exec_domains + .iter() + .find(|ed| ed.name == self.name) + .cloned() + } + pub fn with_pty_system(name: &str, pty_system: Box) -> Self { let id = alloc_domain_id(); Self { @@ -190,7 +197,6 @@ impl LocalDomain { id, name: name.to_string(), wsl: None, - exec_domain: None, } } @@ -201,9 +207,7 @@ impl LocalDomain { } pub fn new_exec_domain(exec_domain: ExecDomain) -> anyhow::Result { - let mut dom = Self::new(&exec_domain.name)?; - dom.exec_domain.replace(exec_domain); - Ok(dom) + Self::new(&exec_domain.name) } #[cfg(unix)] @@ -261,7 +265,7 @@ impl LocalDomain { cmd.clear_cwd(); *cmd.get_argv_mut() = argv; - } else if let Some(ed) = &self.exec_domain { + } else if let Some(ed) = self.resolve_exec_domain() { let mut args = vec![]; let mut set_environment_variables = HashMap::new(); for arg in cmd.get_argv() { @@ -439,7 +443,7 @@ impl Domain for LocalDomain { } async fn domain_label(&self) -> String { - if let Some(ed) = &self.exec_domain { + if let Some(ed) = self.resolve_exec_domain() { match &ed.label { Some(ValueOrFunc::Value(wezterm_dynamic::Value::String(s))) => s.to_string(), Some(ValueOrFunc::Func(label_func)) => {