aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-utils/src
diff options
context:
space:
mode:
authoruser <user@clank>2026-08-11 17:00:37 +0200
committeruser <user@clank>2026-08-11 17:00:37 +0200
commit508b5aa87ced4c7aab38bcb0e34c4158e5b4e101 (patch)
tree511485d45371596801f25354f62bc938e882a890 /zellij-utils/src
parentsl0p: warn when the responsive layout has no swap layout to collapse into (diff)
downloadsl0ppij-508b5aa87ced4c7aab38bcb0e34c4158e5b4e101.tar.gz
sl0ppij-508b5aa87ced4c7aab38bcb0e34c4158e5b4e101.tar.xz
sl0ppij-508b5aa87ced4c7aab38bcb0e34c4158e5b4e101.zip
sl0p: synthesize a stack layout when none exists to collapse into
The collapse selects a swap layout by name, and a custom layout file only gets swap layouts from a hand-written sibling "<layout>.swap.kdl". So for most layouts there was nothing to select and the feature silently did nothing -- requiring a boilerplate file per layout to use it at all. Now a missing layout is synthesized: every pane flattened into one stack, in layout order. Appended rather than inserted, so it cannot shift the BASE layout at position 0, which is what the collapse restores back to. Synthesized lazily, at the first collapse, rather than up front: a stack sitting in the swap cycle would let auto_layout apply it spontaneously when a pane is added, stacking panes on a perfectly wide terminal. Also scopes the damaged-layout guard. With no swap layouts, relayout finds nothing applicable on the first pane added, gives up and marks the tab damaged -- permanently, and with nothing to do with user intent. Honouring that flag disabled the collapse for exactly the bare layouts this fallback targets, so it is now only consulted when the tab has swap layouts the user actually defined.
Diffstat (limited to 'zellij-utils/src')
-rw-r--r--zellij-utils/src/input/layout.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/zellij-utils/src/input/layout.rs b/zellij-utils/src/input/layout.rs
index 4162811f..912464f4 100644
--- a/zellij-utils/src/input/layout.rs
+++ b/zellij-utils/src/input/layout.rs
@@ -959,6 +959,29 @@ pub struct TiledPaneLayout {
}
impl TiledPaneLayout {
+ /// A layout that flattens whatever panes it receives into one stack, in the
+ /// order they appear.
+ ///
+ /// Synthesized when a responsive collapse is configured but the layout has
+ /// no swap layout to collapse into -- which is the normal case, since a
+ /// custom layout only gets swap layouts from a hand-written sibling
+ /// `<layout>.swap.kdl`. Equivalent to:
+ ///
+ /// ```kdl
+ /// pane stacked=true { children; }
+ /// ```
+ pub fn single_stack() -> Self {
+ TiledPaneLayout {
+ children_are_stacked: true,
+ // where the tab's existing panes get inserted; the stack keeps them
+ // in layout order
+ external_children_index: Some(0),
+ // NB: a stacked pane may not split vertically, and Horizontal is the
+ // Default, but state it rather than rely on that staying true
+ children_split_direction: SplitDirection::Horizontal,
+ ..Default::default()
+ }
+ }
pub fn insert_children_layout(
&mut self,
children_layout: &mut TiledPaneLayout,