fix(layouts): do not relayout twice on auto_layout (#2202)
* fix(layouts): do not relayout twice on auto_layout * style(fmt): rustfmt
This commit is contained in:
parent
4d1b127543
commit
b3b0ddbab8
10 changed files with 67 additions and 222 deletions
|
|
@ -160,7 +160,27 @@ impl TiledPanes {
|
||||||
self.move_clients_between_panes(pane_id, with_pane_id);
|
self.move_clients_between_panes(pane_id, with_pane_id);
|
||||||
removed_pane
|
removed_pane
|
||||||
}
|
}
|
||||||
pub fn insert_pane(&mut self, pane_id: PaneId, mut pane: Box<dyn Pane>) {
|
pub fn insert_pane(&mut self, pane_id: PaneId, pane: Box<dyn Pane>) {
|
||||||
|
let should_relayout = true;
|
||||||
|
self.add_pane(pane_id, pane, should_relayout);
|
||||||
|
}
|
||||||
|
pub fn insert_pane_without_relayout(&mut self, pane_id: PaneId, pane: Box<dyn Pane>) {
|
||||||
|
let should_relayout = false;
|
||||||
|
self.add_pane(pane_id, pane, should_relayout);
|
||||||
|
}
|
||||||
|
pub fn has_room_for_new_pane(&mut self) -> bool {
|
||||||
|
let cursor_height_width_ratio = self.cursor_height_width_ratio();
|
||||||
|
let pane_grid = TiledPaneGrid::new(
|
||||||
|
&mut self.panes,
|
||||||
|
&self.panes_to_hide,
|
||||||
|
*self.display_area.borrow(),
|
||||||
|
*self.viewport.borrow(),
|
||||||
|
);
|
||||||
|
pane_grid
|
||||||
|
.find_room_for_new_pane(cursor_height_width_ratio)
|
||||||
|
.is_some()
|
||||||
|
}
|
||||||
|
fn add_pane(&mut self, pane_id: PaneId, mut pane: Box<dyn Pane>, should_relayout: bool) {
|
||||||
let cursor_height_width_ratio = self.cursor_height_width_ratio();
|
let cursor_height_width_ratio = self.cursor_height_width_ratio();
|
||||||
let pane_grid = TiledPaneGrid::new(
|
let pane_grid = TiledPaneGrid::new(
|
||||||
&mut self.panes,
|
&mut self.panes,
|
||||||
|
|
@ -178,22 +198,12 @@ impl TiledPanes {
|
||||||
pane_to_split.set_geom(first_geom);
|
pane_to_split.set_geom(first_geom);
|
||||||
pane.set_geom(second_geom);
|
pane.set_geom(second_geom);
|
||||||
self.panes.insert(pane_id, pane);
|
self.panes.insert(pane_id, pane);
|
||||||
self.relayout(!split_direction);
|
if should_relayout {
|
||||||
|
self.relayout(!split_direction);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn has_room_for_new_pane(&mut self) -> bool {
|
|
||||||
let cursor_height_width_ratio = self.cursor_height_width_ratio();
|
|
||||||
let pane_grid = TiledPaneGrid::new(
|
|
||||||
&mut self.panes,
|
|
||||||
&self.panes_to_hide,
|
|
||||||
*self.display_area.borrow(),
|
|
||||||
*self.viewport.borrow(),
|
|
||||||
);
|
|
||||||
pane_grid
|
|
||||||
.find_room_for_new_pane(cursor_height_width_ratio)
|
|
||||||
.is_some()
|
|
||||||
}
|
|
||||||
pub fn fixed_pane_geoms(&self) -> Vec<Viewport> {
|
pub fn fixed_pane_geoms(&self) -> Vec<Viewport> {
|
||||||
self.panes
|
self.panes
|
||||||
.values()
|
.values()
|
||||||
|
|
|
||||||
|
|
@ -609,7 +609,7 @@ impl ExistingTabState {
|
||||||
default_to_closest_position: bool,
|
default_to_closest_position: bool,
|
||||||
) -> Vec<(&PaneId, &Box<dyn Pane>)> {
|
) -> Vec<(&PaneId, &Box<dyn Pane>)> {
|
||||||
let mut candidates: Vec<_> = self.existing_panes.iter().collect();
|
let mut candidates: Vec<_> = self.existing_panes.iter().collect();
|
||||||
candidates.sort_by(|(_a_id, a), (_b_id, b)| {
|
candidates.sort_by(|(a_id, a), (b_id, b)| {
|
||||||
let a_invoked_with = a.invoked_with();
|
let a_invoked_with = a.invoked_with();
|
||||||
let b_invoked_with = b.invoked_with();
|
let b_invoked_with = b.invoked_with();
|
||||||
if Run::is_same_category(run, a_invoked_with)
|
if Run::is_same_category(run, a_invoked_with)
|
||||||
|
|
@ -637,7 +637,7 @@ impl ExistingTabState {
|
||||||
let b_y_distance = abs(b.position_and_size().y, position_and_size.y);
|
let b_y_distance = abs(b.position_and_size().y, position_and_size.y);
|
||||||
(a_x_distance + a_y_distance).cmp(&(b_x_distance + b_y_distance))
|
(a_x_distance + a_y_distance).cmp(&(b_x_distance + b_y_distance))
|
||||||
} else {
|
} else {
|
||||||
std::cmp::Ordering::Equal
|
a_id.cmp(&b_id) // just so it's a stable sort
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1017,6 +1017,7 @@ impl Tab {
|
||||||
if self.tiled_panes.fullscreen_is_active() {
|
if self.tiled_panes.fullscreen_is_active() {
|
||||||
self.tiled_panes.unset_fullscreen();
|
self.tiled_panes.unset_fullscreen();
|
||||||
}
|
}
|
||||||
|
let should_auto_layout = self.auto_layout && !self.swap_layouts.is_tiled_damaged();
|
||||||
if self.tiled_panes.has_room_for_new_pane() {
|
if self.tiled_panes.has_room_for_new_pane() {
|
||||||
if let PaneId::Terminal(term_pid) = pid {
|
if let PaneId::Terminal(term_pid) = pid {
|
||||||
let next_terminal_position = self.get_next_terminal_position();
|
let next_terminal_position = self.get_next_terminal_position();
|
||||||
|
|
@ -1035,14 +1036,21 @@ impl Tab {
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
new_terminal.set_active_at(Instant::now());
|
new_terminal.set_active_at(Instant::now());
|
||||||
self.tiled_panes.insert_pane(pid, Box::new(new_terminal));
|
if should_auto_layout {
|
||||||
|
// no need to relayout here, we'll do it when reapplying the swap layout
|
||||||
|
// below
|
||||||
|
self.tiled_panes
|
||||||
|
.insert_pane_without_relayout(pid, Box::new(new_terminal));
|
||||||
|
} else {
|
||||||
|
self.tiled_panes.insert_pane(pid, Box::new(new_terminal));
|
||||||
|
}
|
||||||
self.should_clear_display_before_rendering = true;
|
self.should_clear_display_before_rendering = true;
|
||||||
if let Some(client_id) = client_id {
|
if let Some(client_id) = client_id {
|
||||||
self.tiled_panes.focus_pane(pid, client_id);
|
self.tiled_panes.focus_pane(pid, client_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if self.auto_layout && !self.swap_layouts.is_tiled_damaged() {
|
if should_auto_layout {
|
||||||
// only do this if we're already in this layout, otherwise it might be
|
// only do this if we're already in this layout, otherwise it might be
|
||||||
// confusing and not what the user intends
|
// confusing and not what the user intends
|
||||||
self.swap_layouts.set_is_tiled_damaged(); // we do this so that we won't skip to the
|
self.swap_layouts.set_is_tiled_damaged(); // we do this so that we won't skip to the
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-server/src/tab/./unit/tab_integration_tests.rs
|
source: zellij-server/src/tab/./unit/tab_integration_tests.rs
|
||||||
assertion_line: 4062
|
assertion_line: 4299
|
||||||
expression: snapshot
|
expression: snapshot
|
||||||
---
|
---
|
||||||
00 (C): ┌ Pane #1 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
00 (C): ┌ Pane #1 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||||
|
|
@ -17,8 +17,8 @@ expression: snapshot
|
||||||
11 (C): │ │
|
11 (C): │ │
|
||||||
12 (C): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
12 (C): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||||
13 (C): ┌ Pane #2 ────────────────────────────────────────────────────────┐┌ Pane #4 ───────────────────────────────────────────┐
|
13 (C): ┌ Pane #2 ────────────────────────────────────────────────────────┐┌ Pane #4 ───────────────────────────────────────────┐
|
||||||
14 (C): │ │┌ Pane #5 ───────────────────────────────────────────┐
|
14 (C): │ │┌ Pane #3 ───────────────────────────────────────────┐
|
||||||
15 (C): │ │┌ Pane #6 ───────────────────────────────────────────┐
|
15 (C): │ │┌ Pane #5 ───────────────────────────────────────────┐
|
||||||
16 (C): │ ││ │
|
16 (C): │ ││ │
|
||||||
17 (C): │ ││ │
|
17 (C): │ ││ │
|
||||||
18 (C): │ ││ │
|
18 (C): │ ││ │
|
||||||
|
|
@ -31,7 +31,7 @@ expression: snapshot
|
||||||
25 (C): │ ││ │
|
25 (C): │ ││ │
|
||||||
26 (C): │ ││ │
|
26 (C): │ ││ │
|
||||||
27 (C): └─────────────────────────────────────────────────────────────────┘└────────────────────────────────────────────────────┘
|
27 (C): └─────────────────────────────────────────────────────────────────┘└────────────────────────────────────────────────────┘
|
||||||
28 (C): ┌ Pane #3 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
28 (C): ┌ Pane #6 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||||
29 (C): │ │
|
29 (C): │ │
|
||||||
30 (C): │ │
|
30 (C): │ │
|
||||||
31 (C): │ │
|
31 (C): │ │
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-server/src/tab/./unit/tab_integration_tests.rs
|
source: zellij-server/src/tab/./unit/tab_integration_tests.rs
|
||||||
assertion_line: 4047
|
assertion_line: 4237
|
||||||
expression: snapshot
|
expression: snapshot
|
||||||
---
|
---
|
||||||
00 (C): ┌ Pane #1 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
00 (C): ┌ Pane #1 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||||
|
|
@ -17,8 +17,8 @@ expression: snapshot
|
||||||
11 (C): │ │
|
11 (C): │ │
|
||||||
12 (C): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
12 (C): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||||
13 (C): ┌ Pane #2 ──────────────────────────────────────────────────┐┌ Pane #4 ─────────────────────────────────────────────────┐
|
13 (C): ┌ Pane #2 ──────────────────────────────────────────────────┐┌ Pane #4 ─────────────────────────────────────────────────┐
|
||||||
14 (C): │ │┌ Pane #5 ─────────────────────────────────────────────────┐
|
14 (C): │ │┌ Pane #3 ─────────────────────────────────────────────────┐
|
||||||
15 (C): │ │┌ Pane #6 ─────────────────────────────────────────────────┐
|
15 (C): │ │┌ Pane #5 ─────────────────────────────────────────────────┐
|
||||||
16 (C): │ ││ │
|
16 (C): │ ││ │
|
||||||
17 (C): │ ││ │
|
17 (C): │ ││ │
|
||||||
18 (C): │ ││ │
|
18 (C): │ ││ │
|
||||||
|
|
@ -28,7 +28,7 @@ expression: snapshot
|
||||||
22 (C): │ ││ │
|
22 (C): │ ││ │
|
||||||
23 (C): │ ││ │
|
23 (C): │ ││ │
|
||||||
24 (C): └───────────────────────────────────────────────────────────┘└──────────────────────────────────────────────────────────┘
|
24 (C): └───────────────────────────────────────────────────────────┘└──────────────────────────────────────────────────────────┘
|
||||||
25 (C): ┌ Pane #3 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
25 (C): ┌ Pane #6 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||||
26 (C): │ │
|
26 (C): │ │
|
||||||
27 (C): │ │
|
27 (C): │ │
|
||||||
28 (C): │ │
|
28 (C): │ │
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-server/src/tab/./unit/tab_integration_tests.rs
|
source: zellij-server/src/tab/./unit/tab_integration_tests.rs
|
||||||
assertion_line: 3823
|
assertion_line: 4024
|
||||||
expression: snapshot
|
expression: snapshot
|
||||||
---
|
---
|
||||||
00 (C): ┌ Pane #1 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
00 (C): ┌ Pane #1 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||||
|
|
@ -17,8 +17,8 @@ expression: snapshot
|
||||||
11 (C): │ │
|
11 (C): │ │
|
||||||
12 (C): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
12 (C): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||||
13 (C): ┌ Pane #2 ───────────────────────────────────────────┐┌ Pane #4 ────────────────────────────────────────────────────────┐
|
13 (C): ┌ Pane #2 ───────────────────────────────────────────┐┌ Pane #4 ────────────────────────────────────────────────────────┐
|
||||||
14 (C): │ │┌ Pane #5 ────────────────────────────────────────────────────────┐
|
14 (C): │ │┌ Pane #3 ────────────────────────────────────────────────────────┐
|
||||||
15 (C): │ │┌ Pane #6 ────────────────────────────────────────────────────────┐
|
15 (C): │ │┌ Pane #5 ────────────────────────────────────────────────────────┐
|
||||||
16 (C): │ ││ │
|
16 (C): │ ││ │
|
||||||
17 (C): │ ││ │
|
17 (C): │ ││ │
|
||||||
18 (C): │ ││ │
|
18 (C): │ ││ │
|
||||||
|
|
@ -31,7 +31,7 @@ expression: snapshot
|
||||||
25 (C): │ ││ │
|
25 (C): │ ││ │
|
||||||
26 (C): │ ││ │
|
26 (C): │ ││ │
|
||||||
27 (C): └────────────────────────────────────────────────────┘└─────────────────────────────────────────────────────────────────┘
|
27 (C): └────────────────────────────────────────────────────┘└─────────────────────────────────────────────────────────────────┘
|
||||||
28 (C): ┌ Pane #3 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
28 (C): ┌ Pane #6 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||||
29 (C): │ │
|
29 (C): │ │
|
||||||
30 (C): │ │
|
30 (C): │ │
|
||||||
31 (C): │ │
|
31 (C): │ │
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-server/src/tab/./unit/tab_integration_tests.rs
|
source: zellij-server/src/tab/./unit/tab_integration_tests.rs
|
||||||
assertion_line: 3807
|
assertion_line: 3961
|
||||||
expression: snapshot
|
expression: snapshot
|
||||||
---
|
---
|
||||||
00 (C): ┌ Pane #1 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
00 (C): ┌ Pane #1 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||||
|
|
@ -17,8 +17,8 @@ expression: snapshot
|
||||||
11 (C): │ │
|
11 (C): │ │
|
||||||
12 (C): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
12 (C): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||||
13 (C): ┌ Pane #2 ──────────────────────────────────────────────────┐┌ Pane #4 ─────────────────────────────────────────────────┐
|
13 (C): ┌ Pane #2 ──────────────────────────────────────────────────┐┌ Pane #4 ─────────────────────────────────────────────────┐
|
||||||
14 (C): │ │┌ Pane #5 ─────────────────────────────────────────────────┐
|
14 (C): │ │┌ Pane #3 ─────────────────────────────────────────────────┐
|
||||||
15 (C): │ │┌ Pane #6 ─────────────────────────────────────────────────┐
|
15 (C): │ │┌ Pane #5 ─────────────────────────────────────────────────┐
|
||||||
16 (C): │ ││ │
|
16 (C): │ ││ │
|
||||||
17 (C): │ ││ │
|
17 (C): │ ││ │
|
||||||
18 (C): │ ││ │
|
18 (C): │ ││ │
|
||||||
|
|
@ -31,7 +31,7 @@ expression: snapshot
|
||||||
25 (C): │ ││ │
|
25 (C): │ ││ │
|
||||||
26 (C): │ ││ │
|
26 (C): │ ││ │
|
||||||
27 (C): └───────────────────────────────────────────────────────────┘└──────────────────────────────────────────────────────────┘
|
27 (C): └───────────────────────────────────────────────────────────┘└──────────────────────────────────────────────────────────┘
|
||||||
28 (C): ┌ Pane #3 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
28 (C): ┌ Pane #6 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||||
29 (C): │ │
|
29 (C): │ │
|
||||||
30 (C): │ │
|
30 (C): │ │
|
||||||
31 (C): │ │
|
31 (C): │ │
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
source: zellij-server/src/tab/./unit/tab_integration_tests.rs
|
source: zellij-server/src/tab/./unit/tab_integration_tests.rs
|
||||||
assertion_line: 4178
|
assertion_line: 4384
|
||||||
expression: snapshot
|
expression: snapshot
|
||||||
---
|
---
|
||||||
00 (C): ┌ Pane #1 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
00 (C): ┌ Pane #1 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||||
|
|
@ -17,11 +17,11 @@ expression: snapshot
|
||||||
11 (C): │ │
|
11 (C): │ │
|
||||||
12 (C): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
12 (C): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||||
13 (C): ┌ Pane #2 ────────────────────────────────────────────────────────┐┌ Pane #4 ───────────────────────────────────────────┐
|
13 (C): ┌ Pane #2 ────────────────────────────────────────────────────────┐┌ Pane #4 ───────────────────────────────────────────┐
|
||||||
14 (C): │ │┌ Pane #6 ───────────────────────────────────────────┐
|
14 (C): │ │┌ Pane #5 ───────────────────────────────────────────┐
|
||||||
15 (C): │ │┌ Pane #7 ───────────────────────────────────────────┐
|
15 (C): │ │┌ Pane #6 ───────────────────────────────────────────┐
|
||||||
16 (C): │ │┌ Pane #8 ───────────────────────────────────────────┐
|
16 (C): │ │┌ Pane #7 ───────────────────────────────────────────┐
|
||||||
17 (C): │ │┌ Pane #9 ───────────────────────────────────────────┐
|
17 (C): │ │┌ Pane #9 ───────────────────────────────────────────┐
|
||||||
18 (C): │ │┌ Pane #10 ──────────────────────────────────────────┐
|
18 (C): │ │┌ Pane #8 ───────────────────────────────────────────┐
|
||||||
19 (C): └─────────────────────────────────────────────────────────────────┘┌ Pane #11 ──────────────────────────────────────────┐
|
19 (C): └─────────────────────────────────────────────────────────────────┘┌ Pane #11 ──────────────────────────────────────────┐
|
||||||
20 (C): ┌ Pane #3 ────────────────────────────────────────────────────────┐│ │
|
20 (C): ┌ Pane #3 ────────────────────────────────────────────────────────┐│ │
|
||||||
21 (C): │ ││ │
|
21 (C): │ ││ │
|
||||||
|
|
@ -30,7 +30,7 @@ expression: snapshot
|
||||||
24 (C): │ ││ │
|
24 (C): │ ││ │
|
||||||
25 (C): │ ││ │
|
25 (C): │ ││ │
|
||||||
26 (C): └─────────────────────────────────────────────────────────────────┘└────────────────────────────────────────────────────┘
|
26 (C): └─────────────────────────────────────────────────────────────────┘└────────────────────────────────────────────────────┘
|
||||||
27 (C): ┌ Pane #5 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
27 (C): ┌ Pane #10 ─────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||||
28 (C): │ │
|
28 (C): │ │
|
||||||
29 (C): │ │
|
29 (C): │ │
|
||||||
30 (C): │ │
|
30 (C): │ │
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
---
|
---
|
||||||
source: zellij-server/src/tab/./unit/tab_integration_tests.rs
|
source: zellij-server/src/tab/./unit/tab_integration_tests.rs
|
||||||
assertion_line: 3378
|
assertion_line: 3476
|
||||||
expression: snapshot
|
expression: snapshot
|
||||||
---
|
---
|
||||||
00 (C): ┌ Pane #3 ──────────────────────────────────────────────────┐┌ Pane #7 ─────────────────────────────────────────────────┐
|
00 (C): ┌ Pane #3 ──────────────────────────────────────────────────┐┌ Pane #2 ─────────────────────────────────────────────────┐
|
||||||
01 (C): ┌ Pane #2 ──────────────────────────────────────────────────┐│ │
|
01 (C): ┌ Pane #4 ──────────────────────────────────────────────────┐│ │
|
||||||
02 (C): ┌ Pane #4 ──────────────────────────────────────────────────┐│ │
|
02 (C): ┌ Pane #5 ──────────────────────────────────────────────────┐│ │
|
||||||
03 (C): ┌ Pane #5 ──────────────────────────────────────────────────┐│ │
|
03 (C): ┌ Pane #6 ──────────────────────────────────────────────────┐│ │
|
||||||
04 (C): ┌ Pane #6 ──────────────────────────────────────────────────┐│ │
|
04 (C): ┌ Pane #7 ──────────────────────────────────────────────────┐│ │
|
||||||
05 (C): ┌ Pane #8 ──────────────────────────────────────────────────┐│ │
|
05 (C): ┌ Pane #8 ──────────────────────────────────────────────────┐│ │
|
||||||
06 (C): ┌ Pane #9 ──────────────────────────────────────────────────┐│ │
|
06 (C): ┌ Pane #9 ──────────────────────────────────────────────────┐│ │
|
||||||
07 (C): ┌ Pane #10 ─────────────────────────────────────────────────┐│ │
|
07 (C): ┌ Pane #10 ─────────────────────────────────────────────────┐│ │
|
||||||
|
|
|
||||||
|
|
@ -4009,7 +4009,8 @@ fn can_increase_size_of_main_pane_in_stack_non_directionally() {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
tab.new_pane(new_pane_id_5, None, None, Some(client_id))
|
tab.new_pane(new_pane_id_5, None, None, Some(client_id))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
tab.move_focus_right(client_id);
|
let _ = tab.move_focus_up(client_id);
|
||||||
|
let _ = tab.move_focus_right(client_id);
|
||||||
tab.resize(client_id, ResizeStrategy::new(Resize::Increase, None))
|
tab.resize(client_id, ResizeStrategy::new(Resize::Increase, None))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
tab.render(&mut output, None).unwrap();
|
tab.render(&mut output, None).unwrap();
|
||||||
|
|
@ -4022,95 +4023,6 @@ fn can_increase_size_of_main_pane_in_stack_non_directionally() {
|
||||||
assert_snapshot!(snapshot);
|
assert_snapshot!(snapshot);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn increasing_size_of_main_pane_in_stack_horizontally_does_not_break_stack() {
|
|
||||||
// here we test a situation where we're increasing the size of the main pane in a stack
|
|
||||||
// while adjacent to this main pane there's another pane perfectly aligned to it
|
|
||||||
// if the pane weren't a member of the stack, we would increase into that adjacent pane
|
|
||||||
// now, we increase all of the stack also into the panes above said pane
|
|
||||||
let size = Size {
|
|
||||||
cols: 121,
|
|
||||||
rows: 40,
|
|
||||||
};
|
|
||||||
let client_id = 1;
|
|
||||||
let mut output = Output::default();
|
|
||||||
let swap_layouts = r#"
|
|
||||||
layout {
|
|
||||||
swap_tiled_layout {
|
|
||||||
tab {
|
|
||||||
pane
|
|
||||||
pane split_direction="vertical" {
|
|
||||||
pane {
|
|
||||||
pane focus=true
|
|
||||||
pane
|
|
||||||
}
|
|
||||||
pane stacked=true { children; }
|
|
||||||
}
|
|
||||||
pane
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"#;
|
|
||||||
let layout = Layout::from_kdl(swap_layouts, "file_name.kdl".into(), None, None).unwrap();
|
|
||||||
let swap_tiled_layouts = layout.swap_tiled_layouts.clone();
|
|
||||||
let swap_floating_layouts = layout.swap_floating_layouts.clone();
|
|
||||||
let mut tab = create_new_tab_with_swap_layouts(
|
|
||||||
size,
|
|
||||||
ModeInfo::default(),
|
|
||||||
(swap_tiled_layouts, swap_floating_layouts),
|
|
||||||
None,
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
let new_pane_id_1 = PaneId::Terminal(2);
|
|
||||||
let new_pane_id_2 = PaneId::Terminal(3);
|
|
||||||
let new_pane_id_3 = PaneId::Terminal(4);
|
|
||||||
let new_pane_id_4 = PaneId::Terminal(5);
|
|
||||||
let new_pane_id_5 = PaneId::Terminal(6);
|
|
||||||
let new_pane_id_6 = PaneId::Terminal(7);
|
|
||||||
let new_pane_id_7 = PaneId::Terminal(8);
|
|
||||||
let new_pane_id_8 = PaneId::Terminal(9);
|
|
||||||
let new_pane_id_9 = PaneId::Terminal(10);
|
|
||||||
let new_pane_id_10 = PaneId::Terminal(11);
|
|
||||||
let new_pane_id_11 = PaneId::Terminal(12);
|
|
||||||
|
|
||||||
tab.new_pane(new_pane_id_1, None, None, Some(client_id))
|
|
||||||
.unwrap();
|
|
||||||
tab.new_pane(new_pane_id_2, None, None, Some(client_id))
|
|
||||||
.unwrap();
|
|
||||||
tab.new_pane(new_pane_id_3, None, None, Some(client_id))
|
|
||||||
.unwrap();
|
|
||||||
tab.new_pane(new_pane_id_4, None, None, Some(client_id))
|
|
||||||
.unwrap();
|
|
||||||
tab.new_pane(new_pane_id_5, None, None, Some(client_id))
|
|
||||||
.unwrap();
|
|
||||||
tab.new_pane(new_pane_id_6, None, None, Some(client_id))
|
|
||||||
.unwrap();
|
|
||||||
tab.new_pane(new_pane_id_7, None, None, Some(client_id))
|
|
||||||
.unwrap();
|
|
||||||
tab.new_pane(new_pane_id_8, None, None, Some(client_id))
|
|
||||||
.unwrap();
|
|
||||||
tab.new_pane(new_pane_id_9, None, None, Some(client_id))
|
|
||||||
.unwrap();
|
|
||||||
tab.new_pane(new_pane_id_10, None, None, Some(client_id))
|
|
||||||
.unwrap();
|
|
||||||
tab.new_pane(new_pane_id_11, None, None, Some(client_id))
|
|
||||||
.unwrap();
|
|
||||||
tab.move_focus_right(client_id);
|
|
||||||
tab.resize(
|
|
||||||
client_id,
|
|
||||||
ResizeStrategy::new(Resize::Increase, Some(Direction::Left)),
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
tab.render(&mut output, None).unwrap();
|
|
||||||
let snapshot = take_snapshot(
|
|
||||||
output.serialize().unwrap().get(&client_id).unwrap(),
|
|
||||||
size.rows,
|
|
||||||
size.cols,
|
|
||||||
Palette::default(),
|
|
||||||
);
|
|
||||||
assert_snapshot!(snapshot);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn can_increase_size_into_pane_stack_horizontally() {
|
fn can_increase_size_into_pane_stack_horizontally() {
|
||||||
let size = Size {
|
let size = Size {
|
||||||
|
|
@ -4285,7 +4197,7 @@ fn can_increase_size_into_pane_stack_non_directionally() {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
tab.new_pane(new_pane_id_5, None, None, Some(client_id))
|
tab.new_pane(new_pane_id_5, None, None, Some(client_id))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
tab.move_focus_left(client_id);
|
let _ = tab.move_focus_up(client_id);
|
||||||
tab.resize(client_id, ResizeStrategy::new(Resize::Increase, None))
|
tab.resize(client_id, ResizeStrategy::new(Resize::Increase, None))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
tab.render(&mut output, None).unwrap();
|
tab.render(&mut output, None).unwrap();
|
||||||
|
|
@ -4298,91 +4210,6 @@ fn can_increase_size_into_pane_stack_non_directionally() {
|
||||||
assert_snapshot!(snapshot);
|
assert_snapshot!(snapshot);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn increasing_size_into_main_pane_in_stack_horizontally_does_not_break_stack() {
|
|
||||||
// here we test a situation where we're increasing the size of the main pane in a stack
|
|
||||||
// while adjacent to this main pane there's another pane perfectly aligned to it
|
|
||||||
// if the pane weren't a member of the stack, we would increase into that adjacent pane
|
|
||||||
// now, we increase all of the stack also into the panes above said pane
|
|
||||||
let size = Size {
|
|
||||||
cols: 121,
|
|
||||||
rows: 40,
|
|
||||||
};
|
|
||||||
let client_id = 1;
|
|
||||||
let mut output = Output::default();
|
|
||||||
let swap_layouts = r#"
|
|
||||||
layout {
|
|
||||||
swap_tiled_layout {
|
|
||||||
tab {
|
|
||||||
pane
|
|
||||||
pane split_direction="vertical" {
|
|
||||||
pane {
|
|
||||||
pane focus=true
|
|
||||||
pane
|
|
||||||
}
|
|
||||||
pane stacked=true { children; }
|
|
||||||
}
|
|
||||||
pane
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"#;
|
|
||||||
let layout = Layout::from_kdl(swap_layouts, "file_name.kdl".into(), None, None).unwrap();
|
|
||||||
let swap_tiled_layouts = layout.swap_tiled_layouts.clone();
|
|
||||||
let swap_floating_layouts = layout.swap_floating_layouts.clone();
|
|
||||||
let mut tab = create_new_tab_with_swap_layouts(
|
|
||||||
size,
|
|
||||||
ModeInfo::default(),
|
|
||||||
(swap_tiled_layouts, swap_floating_layouts),
|
|
||||||
None,
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
let new_pane_id_1 = PaneId::Terminal(2);
|
|
||||||
let new_pane_id_2 = PaneId::Terminal(3);
|
|
||||||
let new_pane_id_3 = PaneId::Terminal(4);
|
|
||||||
let new_pane_id_4 = PaneId::Terminal(5);
|
|
||||||
let new_pane_id_5 = PaneId::Terminal(6);
|
|
||||||
let new_pane_id_6 = PaneId::Terminal(7);
|
|
||||||
let new_pane_id_7 = PaneId::Terminal(8);
|
|
||||||
let new_pane_id_8 = PaneId::Terminal(9);
|
|
||||||
let new_pane_id_9 = PaneId::Terminal(10);
|
|
||||||
let new_pane_id_10 = PaneId::Terminal(11);
|
|
||||||
|
|
||||||
tab.new_pane(new_pane_id_1, None, None, Some(client_id))
|
|
||||||
.unwrap();
|
|
||||||
tab.new_pane(new_pane_id_2, None, None, Some(client_id))
|
|
||||||
.unwrap();
|
|
||||||
tab.new_pane(new_pane_id_3, None, None, Some(client_id))
|
|
||||||
.unwrap();
|
|
||||||
tab.new_pane(new_pane_id_4, None, None, Some(client_id))
|
|
||||||
.unwrap();
|
|
||||||
tab.new_pane(new_pane_id_5, None, None, Some(client_id))
|
|
||||||
.unwrap();
|
|
||||||
tab.new_pane(new_pane_id_6, None, None, Some(client_id))
|
|
||||||
.unwrap();
|
|
||||||
tab.new_pane(new_pane_id_7, None, None, Some(client_id))
|
|
||||||
.unwrap();
|
|
||||||
tab.new_pane(new_pane_id_8, None, None, Some(client_id))
|
|
||||||
.unwrap();
|
|
||||||
tab.new_pane(new_pane_id_9, None, None, Some(client_id))
|
|
||||||
.unwrap();
|
|
||||||
tab.new_pane(new_pane_id_10, None, None, Some(client_id))
|
|
||||||
.unwrap();
|
|
||||||
tab.resize(
|
|
||||||
client_id,
|
|
||||||
ResizeStrategy::new(Resize::Increase, Some(Direction::Right)),
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
tab.render(&mut output, None).unwrap();
|
|
||||||
let snapshot = take_snapshot(
|
|
||||||
output.serialize().unwrap().get(&client_id).unwrap(),
|
|
||||||
size.rows,
|
|
||||||
size.cols,
|
|
||||||
Palette::default(),
|
|
||||||
);
|
|
||||||
assert_snapshot!(snapshot);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn decreasing_size_of_whole_tab_treats_stacked_panes_properly() {
|
fn decreasing_size_of_whole_tab_treats_stacked_panes_properly() {
|
||||||
let size = Size {
|
let size = Size {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue