diff options
| author | user <user@clank> | 2026-08-08 23:54:38 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-08-08 23:54:38 +0200 |
| commit | 813d4b80658bfb717d93d539019d970b6fbbd1d0 (patch) | |
| tree | 22849b81eb2a5aa35b9ab8fb964d40374047f294 /src/widgets/tabs.rs | |
| parent | chore: bump version to v0.24.0 (diff) | |
| download | sl0pstatus-main.tar.gz sl0pstatus-main.tar.xz sl0pstatus-main.zip | |
Double-clicking a tab in the bar switches to it and drops into RenameTab mode,
matching the double-click-to-rename we added for panes in the sl0ppij zellij
fork. Enter commits, Esc cancels, exactly as the rename keybind does.
Widgets are held behind &self and cannot keep click state, so double-click
detection lives centrally in ModuleConfig::handle_mouse_action and is passed
to Widget::process_click as a flag.
THE TRAP, and the reason this is not a two-line change:
handle_mouse_action also runs for Mouse::Release. A single click therefore
arrives as LeftClick followed by Release at the SAME position. Counting
releases would make every single click register as a double click, and
resetting on release would mean a real double click never registers at all,
since the release falls between the two clicks. Only LeftClick participates;
Release neither counts nor resets.
A completed pair is consumed, so a triple click does not fire a second rename.
switch_tab_to() is called before switch_to_input_mode(), because RenameTab acts
on the ACTIVE tab - renaming without switching first would rename the wrong one.
Threshold is 400ms, the same one zellij uses for text-selection double clicks,
so the bar feels consistent with the panes.
Detection is extracted as register_click_for_double_click() so it can be tested
without constructing a ModuleConfig. Tests cover: a real double click, the
release-in-between regression, too-slow clicks, clicks at different positions,
and the triple-click case.
Upstream tests still pass: 25 total (20 upstream + 5 new).
Note: this repo's .cargo/config.toml targets wasm32-wasip1 and runs tests under
wasmtime, which is not installed here. Tests are run with
`cargo test --target x86_64-unknown-linux-gnu` instead.
Diffstat (limited to 'src/widgets/tabs.rs')
| -rw-r--r-- | src/widgets/tabs.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/widgets/tabs.rs b/src/widgets/tabs.rs index b62f581..970449a 100644 --- a/src/widgets/tabs.rs +++ b/src/widgets/tabs.rs @@ -2,7 +2,7 @@ use std::{cmp, collections::BTreeMap}; use zellij_tile::{ prelude::{InputMode, ModeInfo, PaneInfo, PaneManifest, TabInfo}, - shim::switch_tab_to, + shim::{switch_tab_to, switch_to_input_mode}, }; use crate::{config::ZellijState, render::FormattedPart}; @@ -178,7 +178,7 @@ impl Widget for TabsWidget { output } - fn process_click(&self, _name: &str, state: &ZellijState, pos: usize) { + fn process_click(&self, _name: &str, state: &ZellijState, pos: usize, is_double_click: bool) { let mut offset = 0; let mut counter = 0; @@ -226,6 +226,13 @@ impl Widget for TabsWidget { if pos > offset && pos < offset + content_len { switch_tab_to(tab.position as u32 + 1); + if is_double_click { + // RenameTab acts on the ACTIVE tab, so the switch above has + // to happen first. Mirrors how the rename keybind works, so + // Enter commits and Esc cancels exactly as usual. + switch_to_input_mode(&InputMode::RenameTab); + } + break; } |
