diff options
author | Aram Drevekenin <aram@poor.dev> | 2023-02-25 11:16:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-25 11:16:11 +0100 |
commit | 5bcc1bb382659da60f29e4fc79336d3f6a727b57 (patch) | |
tree | e54fed009064e6d10d630c2c80070873f6a1fce6 | |
parent | d65e8220b67ed7324bc4d79f265f6519c516e198 (diff) |
fix(layout): various parser and ui fixes (#2191)
* fix(layout): error on nodes outside layout node
* fix(layout): move stacked property to pane
* fix(layout): various stack exceptions
* fix(ui): non-flexible stacked pane titles now take up their full length
* fix(ui): stack titles with no-pane-frames take up their proper length
* style(fmt): rustfmt
11 files changed, 391 insertions, 99 deletions
diff --git a/zellij-server/src/panes/terminal_pane.rs b/zellij-server/src/panes/terminal_pane.rs index be14b74f5..d48df67a7 100644 --- a/zellij-server/src/panes/terminal_pane.rs +++ b/zellij-server/src/panes/terminal_pane.rs @@ -358,13 +358,7 @@ impl Pane for TerminalPane { self.pane_name.clone() }; - let mut frame_geom = self.current_geom(); - if !frame_params.should_draw_pane_frames { - // in this case the width of the frame needs not include the pane corners - frame_geom - .cols - .set_inner(frame_geom.cols.as_usize().saturating_sub(1)); - } + let frame_geom = self.current_geom(); let mut frame = PaneFrame::new( frame_geom.into(), self.grid.scrollback_position_and_length(), diff --git a/zellij-server/src/tab/unit/snapshots/zellij_server__tab__tab_integration_tests__swap_tiled_layout_with_stacked_children_and_no_pane_frames.snap b/zellij-server/src/tab/unit/snapshots/zellij_server__tab__tab_integration_tests__swap_tiled_layout_with_stacked_children_and_no_pane_frames.snap index 7174f10a2..ee77150ce 100644 --- a/zellij-server/src/tab/unit/snapshots/zellij_server__tab__tab_integration_tests__swap_tiled_layout_with_stacked_children_and_no_pane_frames.snap +++ b/zellij-server/src/tab/unit/snapshots/zellij_server__tab__tab_integration_tests__swap_tiled_layout_with_stacked_children_and_no_pane_frames.snap @@ -1,11 +1,11 @@ --- source: zellij-server/src/tab/./unit/tab_integration_tests.rs -assertion_line: 3204 +assertion_line: 3249 expression: snapshot --- -00 (C): ├─ Pane #2 ───────────────────────────────────────────────── -01 (C): ├─ Pane #3 ───────────────────────────────────────────────── -02 (C): ├─ Pane #4 ───────────────────────────────────────────────── +00 (C): ├─ Pane #2 ────────────────────────────────────────────────── +01 (C): ├─ Pane #3 ────────────────────────────────────────────────── +02 (C): ├─ Pane #4 ────────────────────────────────────────────────── 03 (C): │ 04 (C): │ 05 (C): │ diff --git a/zellij-server/src/tab/unit/tab_integration_tests.rs b/zellij-server/src/tab/unit/tab_integration_tests.rs index 89e856444..b7823dc1c 100644 --- a/zellij-server/src/tab/unit/tab_integration_tests.rs +++ b/zellij-server/src/tab/unit/tab_integration_tests.rs @@ -3163,7 +3163,7 @@ fn swap_tiled_layout_with_stacked_children() { tab { pane split_direction="vertical" { pane focus=true - pane { children stacked=true; } + pane stacked=true { children; } } } } @@ -3213,7 +3213,7 @@ fn swap_tiled_layout_with_stacked_children_and_no_pane_frames() { tab { pane split_direction="vertical" { pane focus=true - pane { children stacked=true; } + pane stacked=true { children; } } } } @@ -3263,7 +3263,7 @@ fn move_focus_up_with_stacked_panes() { tab { pane split_direction="vertical" { pane focus=true - pane { children stacked=true; } + pane stacked=true { children; } } } } @@ -3315,7 +3315,7 @@ fn move_focus_down_with_stacked_panes() { tab { pane split_direction="vertical" { pane focus=true - pane { children stacked=true; } + pane stacked=true { children; } } } } @@ -3371,7 +3371,7 @@ fn move_focus_right_into_stacked_panes() { tab { pane split_direction="vertical" { pane - pane { children stacked=true; } + pane stacked=true { children; } } } } @@ -3431,7 +3431,7 @@ fn move_focus_left_into_stacked_panes() { swap_tiled_layout { tab { pane split_direction="vertical" { - pane { children stacked=true; } + pane stacked=true { children; } pane focus=true } } @@ -3494,7 +3494,7 @@ fn move_focus_up_into_stacked_panes() { pane pane split_direction="vertical" { pane focus=true - pane { children stacked=true; } + pane stacked=true { children; } } pane } @@ -3558,7 +3558,7 @@ fn move_focus_down_into_stacked_panes() { pane pane split_direction="vertical" { pane focus=true - pane { children stacked=true; } + pane stacked=true { children; } } pane } @@ -3617,7 +3617,7 @@ fn close_main_stacked_pane() { tab { pane split_direction="vertical" { pane focus=true - pane { children stacked=true; } + pane stacked=true { children; } } } } @@ -3668,7 +3668,7 @@ fn close_main_stacked_pane_in_mid_stack() { tab { pane split_direction="vertical" { pane focus=true - pane { children stacked=true; } + pane stacked=true { children; } } } } @@ -3728,7 +3728,7 @@ fn close_one_liner_stacked_pane_below_main_pane() { tab { pane split_direction="vertical" { pane focus=true - pane { children stacked=true; } + pane stacked=true { children; } } } } @@ -3789,7 +3789,7 @@ fn close_one_liner_stacked_pane_above_main_pane() { tab { pane split_direction="vertical" { pane focus=true - pane { children stacked=true; } + pane stacked=true { children; } } } } @@ -3849,7 +3849,7 @@ fn can_increase_size_of_main_pane_in_stack_horizontally() { tab { pane split_direction="vertical" { pane focus=true - pane { children stacked=true; } + pane stacked=true { children; } } } } @@ -3912,7 +3912,7 @@ fn can_increase_size_of_main_pane_in_stack_vertically() { pane pane split_direction="vertical" { pane focus=true - pane { children stacked=true; } + pane stacked=true { children; } } pane } @@ -3976,7 +3976,7 @@ fn can_increase_size_of_main_pane_in_stack_non_directionally() { pane pane split_direction="vertical" { pane focus=true - pane { children stacked=true; } + pane stacked=true { children; } } pane } @@ -4044,7 +4044,7 @@ fn increasing_size_of_main_pane_in_stack_horizontally_does_not_break_stack() { pane focus=true pane } - pane { children stacked=true; } + pane stacked=true { children; } } pane } @@ -4125,7 +4125,7 @@ fn can_increase_size_into_pane_stack_horizontally() { tab { pane split_direction="vertical" { pane focus=true - pane { children stacked=true; } + pane stacked=true { children; } } } } @@ -4187,7 +4187,7 @@ fn can_increase_size_into_pane_stack_vertically() { pane pane split_direction="vertical" { pane focus=true - pane { children stacked=true; } + pane stacked=true { children; } } pane } @@ -4252,7 +4252,7 @@ fn can_increase_size_into_pane_stack_non_directionally() { pane pane split_direction="vertical" { pane focus=true - pane { children stacked=true; } + pane stacked=true { children; } } pane } @@ -4320,7 +4320,7 @@ fn increasing_size_into_main_pane_in_stack_horizontally_does_not_break_stack() { pane focus=true pane } - pane { children stacked=true; } + pane stacked=true { children; } } pane } @@ -4397,7 +4397,7 @@ fn decreasing_size_of_whole_tab_treats_stacked_panes_properly() { tab { pane split_direction="vertical" { pane focus=true - pane { children stacked=true; } + pane stacked=true { children; } } } } @@ -4457,7 +4457,7 @@ fn increasing_size_of_whole_tab_treats_stacked_panes_properly() { tab { pane split_direction="vertical" { pane focus=true - pane { children stacked=true; } + pane stacked=true { children; } } } } @@ -4521,7 +4521,7 @@ fn cannot_decrease_stack_size_beyond_minimum_height() { tab { pane split_direction="vertical" { pane focus=true - pane { children stacked=true; } + pane stacked=true { children; } } pane } @@ -4586,7 +4586,7 @@ fn focus_stacked_pane_over_flexible_pane_with_the_mouse() { tab { pane split_direction="vertical" { pane focus=true - pane { children stacked=true; } + pane stacked=true { children; } } pane } @@ -4645,7 +4645,7 @@ fn focus_stacked_pane_under_flexible_pane_with_the_mouse() { tab { pane split_direction="vertical" { pane focus=true - pane { children stacked=true; } + pane stacked=true { children; } } pane } @@ -4706,7 +4706,7 @@ fn close_stacked_pane_with_previously_focused_other_pane() { tab { pane split_direction="vertical" { pane focus=true - pane { children stacked=true; } + pane stacked=true { children; } } pane } @@ -4774,7 +4774,7 @@ fn close_pane_near_stacked_panes() { tab { pane split_direction="vertical" { pane - pane { children stacked=true; } + pane stacked=true { children; } } } } @@ -4837,7 +4837,7 @@ fn focus_next_pane_expands_stacked_panes() { tab { pane split_direction="vertical" { pane focus=true - pane { children stacked=true; } + pane stacked=true { children; } } pane } @@ -4897,7 +4897,7 @@ fn stacked_panes_can_become_fullscreen() { tab { pane split_direction="vertical" { pane focus=true - pane { children stacked=true; } + pane stacked=true { children; } } pane } diff --git a/zellij-server/src/ui/pane_boundaries_frame.rs b/zellij-server/src/ui/pane_boundaries_frame.rs index 61ec7a4b9..7f8d80171 100644 --- a/zellij-server/src/ui/pane_boundaries_frame.rs +++ b/zellij-server/src/ui/pane_boundaries_frame.rs @@ -343,7 +343,9 @@ impl PaneFrame { self.render_my_and_others_focus(max_length) } else if !self.other_focused_clients.is_empty() { self.render_other_focused_users(max_length) - } else if self.pane_is_stacked_under || self.pane_is_stacked_over { + } else if (self.pane_is_stacked_under || self.pane_is_stacked_over) + && self.exit_status.is_some() + { let (first_part, first_part_len) = self.first_exited_held_title_part_full(); if first_part_len <= max_length { Some((first_part, first_part_len)) diff --git a/zellij-utils/assets/layouts/compact.swap.kdl b/zellij-utils/assets/layouts/compact.swap.kdl index e38fa2101..da9fd593c 100644 --- a/zellij-utils/assets/layouts/compact.swap.kdl +++ b/zellij-utils/assets/layouts/compact.swap.kdl @@ -51,7 +51,7 @@ swap_tiled_layout name="stacked" { ui min_panes=4 { pane split_direction="vertical" { pane - pane { children stacked=true; } + pane stacked=true { children; } } } } diff --git a/zellij-utils/assets/layouts/default.swap.kdl b/zellij-utils/assets/layouts/default.swap.kdl index 51e8afed0..014ce43fb 100644 --- a/zellij-utils/assets/layouts/default.swap.kdl +++ b/zellij-utils/assets/layouts/default.swap.kdl @@ -54,7 +54,7 @@ swap_tiled_layout name="stacked" { ui min_panes=5 { pane split_direction="vertical" { pane - pane { children stacked=true; } + pane stacked=true { children; } } } } diff --git a/zellij-utils/assets/layouts/strider.swap.kdl b/zellij-utils/assets/layouts/strider.swap.kdl index c6df15755..95d219b23 100644 --- a/zellij-utils/assets/layouts/strider.swap.kdl +++ b/zellij-utils/assets/layouts/strider.swap.kdl @@ -62,7 +62,7 @@ swap_tiled_layout name="stacked" { ui min_panes=6 { pane split_direction="vertical" { pane focus=true - pane { children stacked=true; } + pane stacked=true { children; } } } } diff --git a/zellij-utils/src/input/unit/layout_test.rs b/zellij-utils/src/input/unit/layout_test.rs index f15fd709d..670273b0f 100644 --- a/zellij-utils/src/input/unit/layout_test.rs +++ b/zellij-utils/src/input/unit/layout_test.rs @@ -1849,3 +1849,96 @@ fn can_load_swap_layouts_from_a_different_file() { .unwrap(); assert_snapshot!(format!("{:#?}", layout)); } + +#[test] +fn can_define_stacked_children_for_pane_node() { + let kdl_layout = r#" + layout { + pane stacked=true { + pane + pane + } + } + "#; + let layout = Layout::from_kdl(kdl_layout, "layout_file_name".into(), None, None).unwrap(); + assert_snapshot!(format!("{:#?}", layout)); +} + +#[test] +fn can_define_stacked_children_for_pane_template() { + let kdl_layout = r#" + layout { + pane_template name="stack" stacked=true { + children + } + stack { + pane + pane + } + } + "#; + let layout = Layout::from_kdl(kdl_layout, "layout_file_name".into(), None, None).unwrap(); + assert_snapshot!(format!("{:#?}", layout)); +} + +#[test] +fn cannot_define_stacked_panes_for_bare_node() { + let kdl_layout = r#" + layout { + pane stacked=true + } + "#; + let layout = Layout::from_kdl(kdl_layout, "layout_file_name".into(), None, None); + assert!(layout.is_err(), "error provided for tab name with space"); +} + +#[test] +fn cannot_define_stacked_panes_with_vertical_split_direction() { + let kdl_layout = r#" + layout { + pane stacked=true split_direction="vertical" { + pane + pane + } + } + "#; + let layout = Layout::from_kdl(kdl_layout, "layout_file_name".into(), None, None); + assert!(layout.is_err(), "error provided for tab name with space"); +} + +#[test] +fn cannot_define_stacked_panes_with_grandchildren() { + let kdl_layout = r#" + layout { + pane stacked=true { + pane { + pane + pane + } + pane + } + } + "#; + let layout = Layout::from_kdl(kdl_layout, "layout_file_name".into(), None, None); + assert!(layout.is_err(), "error provided for tab name with space"); +} + +#[test] +fn cannot_define_stacked_panes_with_grandchildren_in_pane_template() { + let kdl_layout = r#" + layout { + pane_template name="stack" stacked=true { + children + } + stack { + pane + pane { + pane + pane + } + } + } + "#; + let layout = Layout::from_kdl(kdl_layout, "layout_file_name".into(), None, None); + assert!(layout.is_err(), "error provided for tab name with space"); +} diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__can_define_stacked_children_for_pane_node.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__can_define_stacked_children_for_pane_node.snap new file mode 100644 index 000000000..74a872bcf --- /dev/null +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__can_define_stacked_children_for_pane_node.snap @@ -0,0 +1,63 @@ +--- +source: zellij-utils/src/input/./unit/layout_test.rs +assertion_line: 1870 +expression: "format!(\"{:#?}\", layout)" +--- +Layout { + tabs: [], + focused_tab_index: None, + template: Some( + ( + TiledPaneLayout { + children_split_direction: Horizontal, + name: None, + children: [ + TiledPaneLayout { + children_split_direction: Horizontal, + name: None, + children: [ + TiledPaneLayout { + children_split_direction: Horizontal, + name: None, + children: [], + split_size: None, + run: None, + borderless: false, + focus: None, + external_children_index: None, + children_are_stacked: false, + }, + TiledPaneLayout { + children_split_direction: Horizontal, + name: None, + children: [], + split_size: None, + run: None, + borderless: false, + focus: None, + external_children_index: None, + children_are_stacked: false, + }, + ], + split_size: None, + run: None, + borderless: false, + focus: None, + external_children_index: None, + children_are_stacked: true, + }, + ], + split_size: None, + run: None, + borderless: false, + focus: None, + external_children_index: None, + children_are_stacked: false, + }, + [], + ), + ), + swap_layouts: [], + swap_tiled_layouts: [], + swap_floating_layouts: [], +} diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__can_define_stacked_children_for_pane_template.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__can_define_stacked_children_for_pane_template.snap new file mode 100644 index 000000000..9653eda53 --- /dev/null +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__layout__layout_test__can_define_stacked_children_for_pane_template.snap @@ -0,0 +1,75 @@ +--- +source: zellij-utils/src/input/./unit/layout_test.rs +assertion_line: 1893 +expression: "format!(\"{:#?}\", layout)" +--- +Layout { + tabs: [], + focused_tab_index: None, + template: Some( + ( + TiledPaneLayout { + children_split_direction: Horizontal, + name: None, + children: [ + TiledPaneLayout { + children_split_direction: Horizontal, + name: None, + children: [ + TiledPaneLayout { + children_split_direction: Horizontal, + name: None, + children: [ + TiledPaneLayout { + children_split_direction: Horizontal, + name: None, + children: [], + split_size: None, + run: None, + borderless: false, + focus: None, + external_children_index: None, + children_are_stacked: false, + }, + TiledPaneLayout { + children_split_direction: Horizontal, + name: None, + children: [], + split_size: None, + run: None, + borderless: false, + focus: None, + external_children_index: None, + children_are_stacked: false, + }, + ], + |