Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(panes): moving and toggling embed/float with frames #1909

Merged
merged 2 commits into from
Nov 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions zellij-server/src/panes/tiled_panes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl TiledPanes {
mut with_pane: Box<dyn Pane>,
) -> Option<Box<dyn Pane>> {
let with_pane_id = with_pane.pid();
if self.draw_pane_frames {
if self.draw_pane_frames && !with_pane.borderless() {
with_pane.set_content_offset(Offset::frame(1));
}
let removed_pane = self.panes.remove(&pane_id).map(|removed_pane| {
Expand Down Expand Up @@ -248,7 +248,7 @@ impl TiledPanes {
}

#[allow(clippy::if_same_then_else)]
if draw_pane_frames & !pane.borderless() {
if draw_pane_frames && !pane.borderless() {
// there's definitely a frame around this pane, offset its contents
pane.set_content_offset(Offset::frame(1));
} else if draw_pane_frames && pane.borderless() {
Expand Down Expand Up @@ -828,6 +828,7 @@ impl TiledPanes {
}
resize_pty!(current_position, self.os_api).unwrap();
current_position.set_should_render(true);
self.set_pane_frames(self.draw_pane_frames);
}
pub fn move_active_pane_down(&mut self, client_id: ClientId) {
if let Some(active_pane_id) = self.get_active_pane_id(client_id) {
Expand Down Expand Up @@ -861,6 +862,7 @@ impl TiledPanes {
}
resize_pty!(current_position, self.os_api).unwrap();
current_position.set_should_render(true);
self.set_pane_frames(self.draw_pane_frames);
}
}
}
Expand Down Expand Up @@ -896,6 +898,7 @@ impl TiledPanes {
}
resize_pty!(current_position, self.os_api).unwrap();
current_position.set_should_render(true);
self.set_pane_frames(self.draw_pane_frames);
}
}
}
Expand Down Expand Up @@ -931,6 +934,7 @@ impl TiledPanes {
}
resize_pty!(current_position, self.os_api).unwrap();
current_position.set_should_render(true);
self.set_pane_frames(self.draw_pane_frames);
}
}
}
Expand Down Expand Up @@ -966,6 +970,7 @@ impl TiledPanes {
}
resize_pty!(current_position, self.os_api).unwrap();
current_position.set_should_render(true);
self.set_pane_frames(self.draw_pane_frames);
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions zellij-server/src/tab/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,11 @@ impl Tab {
return Ok(());
}
if let Some(mut embedded_pane_to_float) = self.close_pane(focused_pane_id, true) {
if self.draw_pane_frames && !embedded_pane_to_float.borderless() {
embedded_pane_to_float.set_content_offset(Offset::frame(1));
} else if !self.draw_pane_frames {
embedded_pane_to_float.set_content_offset(Offset::default());
}
embedded_pane_to_float.set_geom(new_pane_geom);
resize_pty!(embedded_pane_to_float, self.os_api).with_context(err_context)?;
embedded_pane_to_float.set_active_at(Instant::now());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
source: zellij-server/src/tab/./unit/tab_integration_tests.rs
assertion_line: 1604
expression: snapshot
---
00 (C): │
01 (C): │
02 (C): │
03 (C): │ I am scratch terminal
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): │

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
source: zellij-server/src/tab/./unit/tab_integration_tests.rs
assertion_line: 1632
expression: snapshot
---
00 (C):
01 (C):
02 (C):
03 (C):
04 (C):
05 (C): ┌ Pane #2 ─────────────────────────────────────────────────┐
06 (C): │ │
07 (C): │ │
08 (C): │ │
09 (C): │ I am an embedded pane │
10 (C): │ │
11 (C): │ │
12 (C): │ │
13 (C): │ │
14 (C): └──────────────────────────────────────────────────────────┘
15 (C):
16 (C):
17 (C):
18 (C):
19 (C):

59 changes: 59 additions & 0 deletions zellij-server/src/tab/unit/tab_integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1573,6 +1573,65 @@ fn float_embedded_pane() {
assert_snapshot!(snapshot);
}

#[test]
fn embed_floating_pane_without_pane_frames() {
let size = Size {
cols: 121,
rows: 20,
};
let client_id = 1;
let mut tab = create_new_tab(size, ModeInfo::default());
let new_pane_id = PaneId::Terminal(2);
let mut output = Output::default();
tab.set_pane_frames(false);
tab.toggle_floating_panes(client_id, None).unwrap();
tab.new_pane(new_pane_id, None, None, Some(client_id))
.unwrap();
tab.handle_pty_bytes(
2,
Vec::from("\n\n\n I am scratch terminal".as_bytes()),
)
.unwrap();
tab.toggle_pane_embed_or_floating(client_id).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]
fn float_embedded_pane_without_pane_frames() {
let size = Size {
cols: 121,
rows: 20,
};
let client_id = 1;
let mut tab = create_new_tab(size, ModeInfo::default());
let new_pane_id = PaneId::Terminal(2);
let mut output = Output::default();
tab.set_pane_frames(false);
tab.new_pane(new_pane_id, None, None, Some(client_id))
.unwrap();
tab.handle_pty_bytes(
2,
Vec::from("\n\n\n I am an embedded pane".as_bytes()),
)
.unwrap();
tab.toggle_pane_embed_or_floating(client_id).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]
fn cannot_float_only_embedded_pane() {
let size = Size {
Expand Down