diff options
| author | user <user@clank> | 2026-08-11 00:12:42 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-08-11 00:12:42 +0200 |
| commit | 26ef6c4e925981c86faed879204056cdc3ccbb93 (patch) | |
| tree | 34a1b96754fe7d6c9186fcd249d0692d210c641e /zellij-server/src/tab/unit | |
| parent | sl0p: collapse to a swap layout when the terminal gets narrow (diff) | |
| download | sl0ppij-26ef6c4e925981c86faed879204056cdc3ccbb93.tar.gz sl0ppij-26ef6c4e925981c86faed879204056cdc3ccbb93.tar.xz sl0ppij-26ef6c4e925981c86faed879204056cdc3ccbb93.zip | |
sl0p: keep stacked-layout entries identifiable
Two problems made the stack list unusable for panes nothing had named yet,
which is the common case right after opening them -- and the responsive
collapse walks straight into it, since collapsing is exactly when the list
becomes the only way to pick a pane.
`hide_default_pane_names` no longer applies to stack list entries. In a frame
an empty title is fine: the pane is still visible, sized and positioned, so
you can tell what it is by looking at it. In the stack list the label is the
ENTIRE affordance, so blanking it leaves rows that cannot be identified or
told apart. Entries fall back to the "Pane #N" placeholder even when frames
are configured to hide it.
Entries are also prefixed with their 1-based position, so they stay countable
and addressable even when several share a title or have none. The prefix is
built by one shared helper because the renderer and Tab's column-width
calculation must agree on its width or the list misaligns.
Diffstat (limited to 'zellij-server/src/tab/unit')
2 files changed, 72 insertions, 7 deletions
diff --git a/zellij-server/src/tab/unit/snapshots/zellij_server__tab__tab_integration_tests__ctrl_scroll_up_merging_stacks_preserves_all_panes.snap b/zellij-server/src/tab/unit/snapshots/zellij_server__tab__tab_integration_tests__ctrl_scroll_up_merging_stacks_preserves_all_panes.snap index e9214f5c..173a0a85 100644 --- a/zellij-server/src/tab/unit/snapshots/zellij_server__tab__tab_integration_tests__ctrl_scroll_up_merging_stacks_preserves_all_panes.snap +++ b/zellij-server/src/tab/unit/snapshots/zellij_server__tab__tab_integration_tests__ctrl_scroll_up_merging_stacks_preserves_all_panes.snap @@ -1,10 +1,11 @@ --- source: zellij-server/src/tab/./unit/tab_integration_tests.rs +assertion_line: 13079 expression: snapshot --- -00 (C): > │ Pane #1 │ -01 (C): │ Pane #3 │ -02 (C): │ Pane #4 │ +00 (C): > │ 1: Pane #1 │ +01 (C): │ 2: Pane #3 │ +02 (C): │ 3: Pane #4 │ 03 (C): 04 (C): ┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ 05 (C): │ │ @@ -24,9 +25,9 @@ expression: snapshot 19 (C): │ │ 20 (C): │ │ 21 (C): └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ -22 (C): │ Pane #2 │ -23 (C): │ Pane #5 │ -24 (C): > │ Pane #6 │ +22 (C): │ 1: Pane #2 │ +23 (C): │ 2: Pane #5 │ +24 (C): > │ 3: Pane #6 │ 25 (C): 26 (C): ┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ 27 (C): │ │ @@ -42,4 +43,3 @@ expression: snapshot 37 (C): │ │ 38 (C): │ │ 39 (C): └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ - diff --git a/zellij-server/src/tab/unit/tab_integration_tests.rs b/zellij-server/src/tab/unit/tab_integration_tests.rs index 145cb621..2449cac9 100644 --- a/zellij-server/src/tab/unit/tab_integration_tests.rs +++ b/zellij-server/src/tab/unit/tab_integration_tests.rs @@ -15931,3 +15931,68 @@ fn sl0p_responsive_layout_restores_even_if_the_layout_is_damaged_while_collapsed widths(&tab) ); } + +#[test] +fn sl0p_stack_list_entry_keeps_a_label_when_default_pane_names_are_hidden() { + // `hide_default_pane_names` blanks the "Pane #N" placeholder, which is what + // we want for a frame: the pane is still visible and positioned, so an empty + // title just looks clean. + // + // The stack list is the opposite case: the label is the entire affordance, + // so blanking it leaves rows that cannot be told apart -- which is exactly + // what happens to freshly created panes, since nothing has named them yet. + // The stack list must therefore keep a label regardless of the option. + let size = Size { + cols: 121, + rows: 20, + }; + let client_id = 1; + let mut tab = create_new_tab(size, ModeInfo::default()); + for pid in [2, 3] { + tab.new_pane( + PaneId::Terminal(pid), + None, + None, + false, + true, + NewPanePlacement::default(), + Some(client_id), + None, + ) + .unwrap(); + } + + tab.update_frame_layout( + zellij_utils::data::PaneTitleAlignment::Left, + 0, + 0, + zellij_utils::data::PanePadding::default(), + 0, + true, // hide_default_pane_names + ); + + for (pane_id, pane) in tab.tiled_panes.panes.iter() { + // precondition: the option really is blanking the frame title, or this + // test would pass for the wrong reason + assert_eq!( + pane.current_title(), + "", + "precondition: {:?} should have a blank FRAME title while \ + hide_default_pane_names is on", + pane_id + ); + let label = pane.stack_list_entry_label(); + assert!( + !label.trim().is_empty(), + "{:?} must still get a stack list label while \ + hide_default_pane_names is on, got {:?}", + pane_id, + label + ); + assert!( + label.contains("Pane #"), + "the stack list label should fall back to the placeholder, got {:?}", + label + ); + } +} |
