Skip to content

Commit

Permalink
fix(tab): frameless pane size wrong after closing other panes (#1776)
Browse files Browse the repository at this point in the history
always recompute pane frames after closing a pane
  • Loading branch information
tlinford authored Oct 12, 2022
1 parent 46dd8d4 commit 694afd2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions zellij-server/src/panes/tiled_panes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 1 addition & 4 deletions zellij-server/src/panes/tiled_panes/tiled_pane_grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
24 changes: 24 additions & 0 deletions zellij-server/src/tab/unit/tab_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

0 comments on commit 694afd2

Please sign in to comment.