fix(panes): moving and toggling embed/float with frames (#1909)
* fix(ui): frame broken or missing when embedding/floating without pane frames * fix(panes): offset properly without pane frames
This commit is contained in:
parent
dde6ecf09a
commit
6c3c0f51d0
5 changed files with 123 additions and 2 deletions
|
|
@ -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| {
|
||||
|
|
@ -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() {
|
||||
|
|
@ -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) {
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
|
|
@ -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): │
|
||||
|
||||
|
|
@ -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):
|
||||
|
||||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue