diff options
| author | Aram Drevekenin <aram@poor.dev> | 2025-03-05 18:42:31 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-05 18:42:31 +0100 |
| commit | 3e694d2e49eec129a85408bd401e0b0324de2ca4 (patch) | |
| tree | 91dd3f4144d89bc496b062ff2da14287b9824417 /zellij-utils/src/input | |
| parent | fix(panes): multiplayer stack issues (#4038) (diff) | |
| download | sl0ppij-3e694d2e49eec129a85408bd401e0b0324de2ca4.tar.gz sl0ppij-3e694d2e49eec129a85408bd401e0b0324de2ca4.tar.xz sl0ppij-3e694d2e49eec129a85408bd401e0b0324de2ca4.zip | |
fix(serialization): stacked panes fixes (#4041)
* fix(serialization): properly handle multiple stacked panes in the same logical node
* fix(layouts): properly handle stacked panes in new layouts
* fix(layouts): properly serialize stacked panes into layouts
* style(fmt): rustfmt
* docs(changelog): update pr
Diffstat (limited to 'zellij-utils/src/input')
| -rw-r--r-- | zellij-utils/src/input/layout.rs | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/zellij-utils/src/input/layout.rs b/zellij-utils/src/input/layout.rs index 8e3dbd53..4738a23f 100644 --- a/zellij-utils/src/input/layout.rs +++ b/zellij-utils/src/input/layout.rs @@ -914,15 +914,25 @@ impl TiledPaneLayout { layout_to_split.focus_deepest_pane(); } + let mut stack_id = 0; split_space( space, &layout_to_split, space, ignore_percent_split_sizes, - 0, + &mut stack_id, + )? + }, + None => { + let mut stack_id = 0; + split_space( + space, + self, + space, + ignore_percent_split_sizes, + &mut stack_id, )? }, - None => split_space(space, self, space, ignore_percent_split_sizes, 0)?, }; for (_pane_layout, pane_geom) in layouts.iter() { if !pane_geom.is_at_least_minimum_size() { @@ -938,10 +948,17 @@ impl TiledPaneLayout { if self.children.is_empty() { run_instructions.push(self.run.clone()); } + let mut run_instructions_of_children = vec![]; for child in &self.children { let mut child_run_instructions = child.extract_run_instructions(); - run_instructions.append(&mut child_run_instructions); + // add the only first child to run_instructions only adding the others after all the + // childfree panes have been added so that the returned vec will be sorted breadth-first + if !child_run_instructions.is_empty() { + run_instructions.push(child_run_instructions.remove(0)); + } + run_instructions_of_children.append(&mut child_run_instructions); } + run_instructions.append(&mut run_instructions_of_children); let mut successfully_ignored = 0; for instruction_to_ignore in &self.run_instructions_to_ignore { if let Some(position) = run_instructions @@ -1617,7 +1634,7 @@ fn split_space( layout: &TiledPaneLayout, total_space_to_split: &PaneGeom, ignore_percent_split_sizes: bool, - mut next_stack_id: usize, + next_stack_id: &mut usize, ) -> Result<Vec<(TiledPaneLayout, PaneGeom)>, &'static str> { let sizes: Vec<Option<SplitSize>> = if layout.children_are_stacked { let index_of_expanded_pane = layout.children.iter().position(|p| p.is_expanded_in_stack); @@ -1631,8 +1648,9 @@ fn split_space( } else if let Some(last_size) = sizes.last_mut() { *last_size = None; } - if sizes.len() > space_to_split.rows.as_usize().saturating_sub(4) { - // 4 is MIN_TERMINAL_HEIGHT + if sizes.len() > space_to_split.rows.as_usize().saturating_sub(3) { + // 4 is MIN_TERMINAL_HEIGHT, minus 1 because sizes also includes the expanded pane in + // the stack return Err("Not enough room for stacked panes in this layout"); } sizes @@ -1687,8 +1705,8 @@ fn split_space( } }); let stacked = if layout.children_are_stacked { - let stack_id = next_stack_id; - next_stack_id += 1; + let stack_id = *next_stack_id; + *next_stack_id += 1; Some(stack_id) } else { None |
