Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select active tab choice as initial choice in ShowTabNavigator #6320

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/config/lua/keyassignment/ShowTabNavigator.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ config.keys = {
}
```

{{since('nightly')}}

The choice corresponding to the current tab is initially selected.

3 changes: 2 additions & 1 deletion wezterm-gui/src/overlay/launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,11 +593,12 @@ pub fn launcher(
args: LauncherArgs,
mut term: TermWizTerminal,
window: ::window::Window,
initial_choice_idx: usize,
) -> anyhow::Result<()> {
let size = term.get_screen_size()?;
let max_items = size.rows.saturating_sub(ROW_OVERHEAD);
let mut state = LauncherState {
active_idx: 0,
active_idx: initial_choice_idx,
max_items,
pane_id: args.pane_id,
top_row: 0,
Expand Down
14 changes: 10 additions & 4 deletions wezterm-gui/src/termwindow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2326,7 +2326,12 @@ impl TermWindow {
}

fn show_tab_navigator(&mut self) {
self.show_launcher_impl("Tab Navigator", LauncherFlags::TABS);
let mux = Mux::get();
let active_tab_idx = match mux.get_window(self.mux_window_id) {
Some(mux_window) => mux_window.get_active_idx(),
None => return,
};
self.show_launcher_impl("Tab Navigator", LauncherFlags::TABS, active_tab_idx);
}

fn show_launcher(&mut self) {
Expand All @@ -2337,10 +2342,11 @@ impl TermWindow {
| LauncherFlags::DOMAINS
| LauncherFlags::KEY_ASSIGNMENTS
| LauncherFlags::COMMANDS,
0,
);
}

fn show_launcher_impl(&mut self, title: &str, flags: LauncherFlags) {
fn show_launcher_impl(&mut self, title: &str, flags: LauncherFlags, initial_choice_idx: usize) {
let mux_window_id = self.mux_window_id;
let window = self.window.as_ref().unwrap().clone();

Expand Down Expand Up @@ -2380,7 +2386,7 @@ impl TermWindow {
let window = window.clone();
let (overlay, future) =
start_overlay(term_window, &tab, move |_tab_id, term| {
launcher(args, term, window)
launcher(args, term, window, initial_choice_idx)
});

term_window.assign_overlay(tab_id, overlay);
Expand Down Expand Up @@ -2704,7 +2710,7 @@ impl TermWindow {
ShowDebugOverlay => self.show_debug_overlay(),
ShowLauncher => self.show_launcher(),
ShowLauncherArgs(args) => {
self.show_launcher_impl(args.title.as_deref().unwrap_or("Launcher"), args.flags)
self.show_launcher_impl(args.title.as_deref().unwrap_or("Launcher"), args.flags, 0)
}
HideApplication => {
let con = Connection::get().expect("call on gui thread");
Expand Down
Loading