mux: try harder to use default_workspace from config

There were a couple of cases where we didn't look at the config
when deciding on the workspace name.

refs: https://github.com/wez/wezterm/issues/2981
This commit is contained in:
Wez Furlong committed 2023-01-19 07:47:27 -07:00
1 parent 5dbdd36a72
commit c042005ee0
4 files changed
+28 -10

No files matched your search

+2
View File
@@ -71,6 +71,8 @@ As features stabilize some brief notes about them will accumulate here.
* Wayland: mouse cursor didn't auto-hide when typing. Thanks to
[@jmbaur](https://github.com/jmbaur)!
[#2977](https://github.com/wez/wezterm/pull/2977)
* mux: `default_workspace` was not always respected when spawning
[#2981](https://github.com/wez/wezterm/issues/2981)
#### Changed
* `CTRL-SHIFT-P` now activates the new command palette, instead of `PaneSelect`
+11 -2
View File
@@ -392,6 +392,15 @@ impl Mux {
}
}
fn get_default_workspace(&self) -> String {
let config = configuration();
config
.default_workspace
.as_deref()
.unwrap_or(DEFAULT_WORKSPACE)
.to_string()
}
pub fn is_main_thread(&self) -> bool {
std::thread::current().id() == self.main_thread_id
}
@@ -496,7 +505,7 @@ impl Mux {
.get(&ident)
.and_then(|info| info.active_workspace.clone())
})
.unwrap_or_else(|| DEFAULT_WORKSPACE.to_string())
.unwrap_or_else(|| self.get_default_workspace())
}
/// Returns the effective active workspace name for a given client
@@ -505,7 +514,7 @@ impl Mux {
.read()
.get(&ident)
.and_then(|info| info.active_workspace.clone())
.unwrap_or_else(|| DEFAULT_WORKSPACE.to_string())
.unwrap_or_else(|| self.get_default_workspace())
}
pub fn set_active_workspace_for_client(&self, ident: &Arc<ClientId>, workspace: &str) {
+6 -7
View File
@@ -642,14 +642,13 @@ fn setup_mux(
let client_id = Arc::new(mux::client::ClientId::new());
mux.register_client(client_id.clone());
mux.replace_identity(Some(client_id));
mux.set_active_workspace(
default_workspace_name.unwrap_or(
config
.default_workspace
.as_deref()
.unwrap_or(mux::DEFAULT_WORKSPACE),
),
let default_workspace_name = default_workspace_name.unwrap_or(
config
.default_workspace
.as_deref()
.unwrap_or(mux::DEFAULT_WORKSPACE),
);
mux.set_active_workspace(&default_workspace_name);
crate::update::load_last_release_info_and_set_banner();
update_mux_domains(config)?;
+9 -1
View File
@@ -1121,7 +1121,15 @@ async fn run_cli_async(config: config::ConfigHandle, cli: CliCommand) -> anyhow:
}
};
let workspace = workspace.unwrap_or_else(|| mux::DEFAULT_WORKSPACE.to_string());
let workspace = workspace
.as_deref()
.unwrap_or(
config
.default_workspace
.as_deref()
.unwrap_or(mux::DEFAULT_WORKSPACE),
)
.to_string();
let size = config.initial_size(0);