mirror of
https://github.com/wez/wezterm.git
synced 2024-12-23 21:32:13 +03:00
config: lazyily produce ssh domain list
I noticed that in debug builds, `wezterm set-working-directory` had high/variable latency, and I traced part of it to the ssh config parsing logic. Make that lazily evaluate the ssh config. refs: #3402
This commit is contained in:
parent
5be7f93317
commit
25255d90d6
@ -325,8 +325,8 @@ pub struct Config {
|
|||||||
#[dynamic(default = "UnixDomain::default_unix_domains")]
|
#[dynamic(default = "UnixDomain::default_unix_domains")]
|
||||||
pub unix_domains: Vec<UnixDomain>,
|
pub unix_domains: Vec<UnixDomain>,
|
||||||
|
|
||||||
#[dynamic(default = "SshDomain::default_domains")]
|
#[dynamic(default)]
|
||||||
pub ssh_domains: Vec<SshDomain>,
|
pub ssh_domains: Option<Vec<SshDomain>>,
|
||||||
|
|
||||||
#[dynamic(default)]
|
#[dynamic(default)]
|
||||||
pub ssh_backend: SshBackend,
|
pub ssh_backend: SshBackend,
|
||||||
@ -828,6 +828,17 @@ impl Config {
|
|||||||
Self::load_with_overrides(&wezterm_dynamic::Value::default())
|
Self::load_with_overrides(&wezterm_dynamic::Value::default())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// It is relatively expensive to parse all the ssh config files,
|
||||||
|
/// so we defer producing the default list until someone explicitly
|
||||||
|
/// asks for it
|
||||||
|
pub fn ssh_domains(&self) -> Vec<SshDomain> {
|
||||||
|
if let Some(domains) = &self.ssh_domains {
|
||||||
|
domains.clone()
|
||||||
|
} else {
|
||||||
|
SshDomain::default_domains()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn update_ulimit(&self) -> anyhow::Result<()> {
|
pub fn update_ulimit(&self) -> anyhow::Result<()> {
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
{
|
{
|
||||||
@ -1127,9 +1138,11 @@ impl Config {
|
|||||||
for d in &self.unix_domains {
|
for d in &self.unix_domains {
|
||||||
check_domain(&d.name, "unix domain")?;
|
check_domain(&d.name, "unix domain")?;
|
||||||
}
|
}
|
||||||
for d in &self.ssh_domains {
|
if let Some(domains) = &self.ssh_domains {
|
||||||
|
for d in domains {
|
||||||
check_domain(&d.name, "ssh domain")?;
|
check_domain(&d.name, "ssh domain")?;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for d in &self.exec_domains {
|
for d in &self.exec_domains {
|
||||||
check_domain(&d.name, "exec domain")?;
|
check_domain(&d.name, "exec domain")?;
|
||||||
}
|
}
|
||||||
|
@ -250,7 +250,7 @@ fn client_domains(config: &config::ConfigHandle) -> Vec<ClientDomainConfig> {
|
|||||||
domains.push(ClientDomainConfig::Unix(unix_dom.clone()));
|
domains.push(ClientDomainConfig::Unix(unix_dom.clone()));
|
||||||
}
|
}
|
||||||
|
|
||||||
for ssh_dom in &config.ssh_domains {
|
for ssh_dom in config.ssh_domains().into_iter() {
|
||||||
if ssh_dom.multiplexing == SshMultiplexing::WezTerm {
|
if ssh_dom.multiplexing == SshMultiplexing::WezTerm {
|
||||||
domains.push(ClientDomainConfig::Ssh(ssh_dom.clone()));
|
domains.push(ClientDomainConfig::Ssh(ssh_dom.clone()));
|
||||||
}
|
}
|
||||||
@ -341,7 +341,7 @@ fn update_mux_domains(config: &ConfigHandle) -> anyhow::Result<()> {
|
|||||||
mux.add_domain(&domain);
|
mux.add_domain(&domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
for ssh_dom in &config.ssh_domains {
|
for ssh_dom in config.ssh_domains().into_iter() {
|
||||||
if ssh_dom.multiplexing != SshMultiplexing::None {
|
if ssh_dom.multiplexing != SshMultiplexing::None {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user