summaryrefslogtreecommitdiffstats
path: root/zellij-server
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2023-02-28 22:08:01 +0100
committerGitHub <noreply@github.com>2023-02-28 22:08:01 +0100
commitea2d9ced6207acd2f401f6d95ac66565cc06d4a9 (patch)
tree8d15cfaeafcb57f849be431e49c85d707d273e8b /zellij-server
parent6a8cf847da8bf1e56f4f713f38231aa9c925230e (diff)
feat(layouts): exact panes constraint (#2206)
* style(fmt): remove warnings * fix(swap-layouts): introduce exact panes constraint * fix(swap-layouts): improve floating pane swap layout ux * style(fmt): rustfmt
Diffstat (limited to 'zellij-server')
-rw-r--r--zellij-server/src/pty.rs2
-rw-r--r--zellij-server/src/tab/swap_layouts.rs14
-rw-r--r--zellij-server/src/tab/unit/snapshots/zellij_server__tab__tab_integration_tests__when_closing_a_pane_in_auto_layout_the_focus_goes_to_last_focused_pane.snap42
-rw-r--r--zellij-server/src/tab/unit/tab_integration_tests.rs6
4 files changed, 36 insertions, 28 deletions
diff --git a/zellij-server/src/pty.rs b/zellij-server/src/pty.rs
index 83255e61c..5daccd17f 100644
--- a/zellij-server/src/pty.rs
+++ b/zellij-server/src/pty.rs
@@ -467,7 +467,7 @@ impl Pty {
TerminalAction::RunCommand(ref mut command) => {
command.cwd = Some(cwd);
},
- TerminalAction::OpenFile(ref file, line_number, ref mut edit_cwd) => {
+ TerminalAction::OpenFile(ref _file, _line_number, ref mut edit_cwd) => {
match edit_cwd.as_mut() {
Some(edit_cwd) => {
*edit_cwd = cwd.join(&edit_cwd);
diff --git a/zellij-server/src/tab/swap_layouts.rs b/zellij-server/src/tab/swap_layouts.rs
index 57085779f..942a65408 100644
--- a/zellij-server/src/tab/swap_layouts.rs
+++ b/zellij-server/src/tab/swap_layouts.rs
@@ -40,12 +40,14 @@ impl SwapLayouts {
let mut base_swap_floating_layout = BTreeMap::new();
let tiled_panes_count = layout.0.pane_count();
let floating_panes_count = layout.1.len();
- // we set MaxPanes to the current panes in the layout, because the base layout is not
+ // we set ExactPanes to the current panes in the layout, because the base layout is not
// intended to be progressive - i.e. to have additional panes added to it
+ // we also don't want it to be applied for less than the expected amount of panes, because
+ // then unintended things can happen
// we still want to keep it around in case we'd like to swap layouts without adding panes
- base_swap_tiled_layout.insert(LayoutConstraint::MaxPanes(tiled_panes_count), layout.0);
+ base_swap_tiled_layout.insert(LayoutConstraint::ExactPanes(tiled_panes_count), layout.0);
base_swap_floating_layout
- .insert(LayoutConstraint::MaxPanes(floating_panes_count), layout.1);
+ .insert(LayoutConstraint::ExactPanes(floating_panes_count), layout.1);
self.swap_tiled_layouts
.insert(0, (base_swap_tiled_layout, Some("BASE".into())));
self.swap_floating_layouts
@@ -174,6 +176,9 @@ impl SwapLayouts {
LayoutConstraint::MinPanes(min_panes) => {
tiled_panes.visible_panes_count() >= *min_panes
},
+ LayoutConstraint::ExactPanes(pane_count) => {
+ tiled_panes.visible_panes_count() == *pane_count
+ },
LayoutConstraint::NoConstraint => true,
}
}
@@ -189,6 +194,9 @@ impl SwapLayouts {
LayoutConstraint::MinPanes(min_panes) => {
floating_panes.visible_panes_count() >= *min_panes
},
+ LayoutConstraint::ExactPanes(pane_count) => {
+ floating_panes.visible_panes_count() == *pane_count
+ },
LayoutConstraint::NoConstraint => true,
}
}
diff --git a/zellij-server/src/tab/unit/snapshots/zellij_server__tab__tab_integration_tests__when_closing_a_pane_in_auto_layout_the_focus_goes_to_last_focused_pane.snap b/zellij-server/src/tab/unit/snapshots/zellij_server__tab__tab_integration_tests__when_closing_a_pane_in_auto_layout_the_focus_goes_to_last_focused_pane.snap
index 8f548b1dc..48fb7d0cd 100644
--- a/zellij-server/src/tab/unit/snapshots/zellij_server__tab__tab_integration_tests__when_closing_a_pane_in_auto_layout_the_focus_goes_to_last_focused_pane.snap
+++ b/zellij-server/src/tab/unit/snapshots/zellij_server__tab__tab_integration_tests__when_closing_a_pane_in_auto_layout_the_focus_goes_to_last_focused_pane.snap
@@ -1,26 +1,26 @@
---
source: zellij-server/src/tab/./unit/tab_integration_tests.rs
-assertion_line: 5333
+assertion_line: 5700
expression: snapshot
---
-00 (C): ┌ Pane #1 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
-01 (C): │ │
-02 (C): │ │
-03 (C): │ │
-04 (C): │ │
-05 (C): │ │
-06 (C): │ │
-07 (C): │ │
-08 (C): │ │
-09 (C): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
-10 (C): ┌ Pane #2 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
-11 (C): │ │
-12 (C): │ │
-13 (C): │ │
-14 (C): │ │
-15 (C): │ │
-16 (C): │ │
-17 (C): │ │
-18 (C): │ │
-19 (C): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
+00 (C): ┌ Pane #1 ──────────────────────────────────────────────────┐┌ Pane #2 ─────────────────────────────────────────────────┐
+01 (C): │ ││ │
+02 (C): │ ││ │
+03 (C): │ ││ │
+04 (C): │ ││ │
+05 (C): │ ││ │
+06 (C): │ ││ │
+07 (C): │ ││ │
+08 (C): │ ││ │
+09 (C): │ ││ │
+10 (C): │ ││ │
+11 (C): │ ││ │
+12 (C): │ ││ │
+13 (C): │ ││ │
+14 (C): │ ││ │
+15 (C): │ ││ │
+16 (C): │ ││ │
+17 (C): │ ││ │
+18 (C): │ ││ │
+19 (C): └───────────────────────────────────────────────────────────┘└──────────────────────────────────────────────────────────┘
diff --git a/zellij-server/src/tab/unit/tab_integration_tests.rs b/zellij-server/src/tab/unit/tab_integration_tests.rs
index 45b3defdf..11de1c298 100644
--- a/zellij-server/src/tab/unit/tab_integration_tests.rs
+++ b/zellij-server/src/tab/unit/tab_integration_tests.rs
@@ -5681,8 +5681,8 @@ fn when_closing_a_pane_in_auto_layout_the_focus_goes_to_last_focused_pane() {
)),
true,
);
- tab.move_focus_down(client_id);
- tab.move_focus_down(client_id);
+ let _ = tab.move_focus_down(client_id);
+ let _ = tab.move_focus_down(client_id);
tab.close_pane(PaneId::Terminal(3), false, Some(client_id));
tab.render(&mut output, None).unwrap();
@@ -5694,7 +5694,7 @@ fn when_closing_a_pane_in_auto_layout_the_focus_goes_to_last_focused_pane() {
);
assert_eq!(
cursor_coordinates,
- Some((1, 11)),
+ Some((62, 1)),
"cursor coordinates moved to the new pane",
);
assert_snapshot!(snapshot);