diff --git a/wezterm-gui/src/overlay/launcher.rs b/wezterm-gui/src/overlay/launcher.rs index 617a24130..c06d5f2e2 100644 --- a/wezterm-gui/src/overlay/launcher.rs +++ b/wezterm-gui/src/overlay/launcher.rs @@ -32,6 +32,7 @@ bitflags::bitflags! { const LAUNCH_MENU_ITEMS = 4; const DOMAINS = 8; const KEY_ASSIGNMENTS = 16; + const WORKSPACES = 32; } } @@ -69,6 +70,8 @@ pub struct LauncherArgs { pane_id: PaneId, domain_id_of_current_tab: DomainId, title: String, + active_workspace: String, + workspaces: Vec, } impl LauncherArgs { @@ -82,6 +85,14 @@ impl LauncherArgs { ) -> Self { let mux = Mux::get().unwrap(); + let active_workspace = mux.active_workspace(); + + let workspaces = if flags.contains(LauncherFlags::WORKSPACES) { + mux.iter_workspaces() + } else { + vec![] + }; + let tabs = if flags.contains(LauncherFlags::TABS) { // Ideally we'd resolve the tabs on the fly once we've started the // overlay, but since the overlay runs in a different thread, accessing @@ -152,6 +163,8 @@ impl LauncherArgs { pane_id, domain_id_of_current_tab, title: title.to_string(), + workspaces, + active_workspace, } } } @@ -254,6 +267,27 @@ impl LauncherState { self.entries.push(entry); } + if args.flags.contains(LauncherFlags::WORKSPACES) { + for ws in &args.workspaces { + if *ws != args.active_workspace { + self.entries.push(Entry { + label: format!("Switch to workspace: `{}`", ws), + kind: EntryKind::KeyAssignment(KeyAssignment::SwitchToWorkspace { + name: Some(ws.clone()), + spawn: None, + }), + }); + } + } + self.entries.push(Entry { + label: "Create new Workspace".to_string(), + kind: EntryKind::KeyAssignment(KeyAssignment::SwitchToWorkspace { + name: None, + spawn: None, + }), + }); + } + for tab in &args.tabs { self.entries.push(Entry { label: format!("{}. {} panes", tab.title, tab.pane_count), diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rs index 81973b9ba..43fd5d8f0 100644 --- a/wezterm-gui/src/termwindow/mod.rs +++ b/wezterm-gui/src/termwindow/mod.rs @@ -1685,6 +1685,7 @@ impl TermWindow { self.show_launcher_impl( "Launcher", LauncherFlags::LAUNCH_MENU_ITEMS + | LauncherFlags::WORKSPACES | LauncherFlags::DOMAINS | LauncherFlags::KEY_ASSIGNMENTS, ); @@ -2091,6 +2092,7 @@ impl TermWindow { tab.toggle_zoom(); } SwitchToWorkspace { name, spawn } => { + let activity = crate::Activity::new(); let mux = Mux::get().unwrap(); let name = name .as_ref() @@ -2122,6 +2124,7 @@ impl TermWindow { log::error!("Failed to spawn: {:#}", err); } switcher.do_switch(); + drop(activity); }) .detach(); } else {