From 694afd223996f5adb0769fef592a5e93a44176e7 Mon Sep 17 00:00:00 2001 From: Thomas Linford Date: Wed, 12 Oct 2022 11:29:17 +0200 Subject: [PATCH] fix(tab): frameless pane size wrong after closing other panes (#1776) always recompute pane frames after closing a pane --- CHANGELOG.md | 1 + zellij-server/src/panes/tiled_panes/mod.rs | 4 +--- .../src/panes/tiled_panes/tiled_pane_grid.rs | 5 +--- zellij-server/src/tab/unit/tab_tests.rs | 24 +++++++++++++++++++ 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b609c771db..d44ff853af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/zellij-server/src/panes/tiled_panes/mod.rs b/zellij-server/src/panes/tiled_panes/mod.rs index fa49710ae0..af7769f3bf 100644 --- a/zellij-server/src/panes/tiled_panes/mod.rs +++ b/zellij-server/src/panes/tiled_panes/mod.rs @@ -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); diff --git a/zellij-server/src/panes/tiled_panes/tiled_pane_grid.rs b/zellij-server/src/panes/tiled_panes/tiled_pane_grid.rs index b8efc5ec3b..2851564a18 100644 --- a/zellij-server/src/panes/tiled_panes/tiled_pane_grid.rs +++ b/zellij-server/src/panes/tiled_panes/tiled_pane_grid.rs @@ -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; diff --git a/zellij-server/src/tab/unit/tab_tests.rs b/zellij-server/src/tab/unit/tab_tests.rs index 2b8d51a130..6b100cf62d 100644 --- a/zellij-server/src/tab/unit/tab_tests.rs +++ b/zellij-server/src/tab/unit/tab_tests.rs @@ -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)); +}