fix(tab): frameless pane size wrong after closing other panes (#1776)

always recompute pane frames after closing a pane
This commit is contained in:
Thomas Linford 2022-10-12 11:29:17 +02:00 committed by GitHub
parent 46dd8d4473
commit 694afd2239
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 7 deletions

View File

@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
* debugging: Improve error format in server/thread_bus (https://github.com/zellij-org/zellij/pull/1775)
* feat: command pane - send commands to Zellij and re-run them with ENTER (https://github.com/zellij-org/zellij/pull/1787)
* fix: escape quotes and backslashes when converting YAML to KDL (https://github.com/zellij-org/zellij/pull/1790)
* fix: frameless pane wrong size after closing other panes (https://github.com/zellij-org/zellij/pull/1776)
## [0.31.4] - 2022-09-09
* Terminal compatibility: improve vttest compliance (https://github.com/zellij-org/zellij/pull/1671)

View File

@ -982,9 +982,7 @@ impl TiledPanes {
// successfully filled space over pane
let closed_pane = self.panes.remove(&pane_id);
self.move_clients_out_of_pane(pane_id);
for pane in self.panes.values_mut() {
resize_pty!(pane, self.os_api);
}
self.set_pane_frames(self.draw_pane_frames); // recalculate pane frames and update size
closed_pane
} else {
self.panes.remove(&pane_id);

View File

@ -1605,10 +1605,7 @@ impl<'a> TiledPaneGrid<'a> {
SplitDirection::Vertical => self.display_area.rows,
SplitDirection::Horizontal => self.display_area.cols,
};
{
let mut panes = self.panes.borrow_mut();
(*panes).remove(&id);
}
self.panes.borrow_mut().remove(&id);
let mut pane_resizer = PaneResizer::new(self.panes.clone());
let _ = pane_resizer.layout(direction, side_length);
return true;

View File

@ -14046,3 +14046,27 @@ pub fn custom_cursor_height_width_ratio() {
"ratio updated successfully"
); // 10 / 4 == 2.5, rounded: 3
}
#[test]
fn correctly_resize_frameless_panes_on_pane_close() {
// check that https://github.com/zellij-org/zellij/issues/1773 is fixed
let cols = 60;
let rows = 20;
let size = Size { cols, rows };
let mut tab = create_new_tab(size);
tab.set_pane_frames(false);
// a single frameless pane should take up all available space
let pane = tab.tiled_panes.panes.get(&PaneId::Terminal(1)).unwrap();
let content_size = (pane.get_content_columns(), pane.get_content_rows());
assert_eq!(content_size, (cols, rows));
tab.new_pane(PaneId::Terminal(2), None, None, Some(1))
.unwrap();
tab.close_pane(PaneId::Terminal(2), true);
// the size should be the same after adding and then removing a pane
let pane = tab.tiled_panes.panes.get(&PaneId::Terminal(1)).unwrap();
let content_size = (pane.get_content_columns(), pane.get_content_rows());
assert_eq!(content_size, (cols, rows));
}