From 77f05f0f12c91df1667e43218074b74dd14c2cf9 Mon Sep 17 00:00:00 2001 From: har7an <99636919+har7an@users.noreply.github.com> Date: Fri, 23 Sep 2022 05:28:35 +0000 Subject: [PATCH] Fix: issue 1734 (#1749) * server/tab: Check suppressed panes when writing to a pane by ID. Previously only the tiled and floating panes would be searched for a pane of a given ID. Fixes: #1734 * server/tab/unit: Test writing to suppressed panes * docs: fix server panics when writing to suppressed panes --- CHANGELOG.md | 1 + zellij-server/src/tab/mod.rs | 4 +++- zellij-server/src/tab/unit/tab_tests.rs | 19 +++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2931e5dc..9051bc8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) * debugging: Improve error handling in screen thread (https://github.com/zellij-org/zellij/pull/1670) * fix: Server exits when client panics (https://github.com/zellij-org/zellij/pull/1731) +* fix: Server panics when writing to suppressed pane (https://github.com/zellij-org/zellij/pull/1749) ## [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/tab/mod.rs b/zellij-server/src/tab/mod.rs index 04626bef..31f3fa1c 100644 --- a/zellij-server/src/tab/mod.rs +++ b/zellij-server/src/tab/mod.rs @@ -1032,7 +1032,9 @@ impl Tab { let active_terminal = self .floating_panes .get(&pane_id) - .unwrap_or_else(|| self.tiled_panes.get_pane(pane_id).unwrap()); + .or_else(|| self.tiled_panes.get_pane(pane_id)) + .or_else(|| self.suppressed_panes.get(&pane_id)) + .unwrap(); let adjusted_input = active_terminal.adjust_input_to_terminal(input_bytes); self.senders diff --git a/zellij-server/src/tab/unit/tab_tests.rs b/zellij-server/src/tab/unit/tab_tests.rs index 2ca6a0cb..8a307250 100644 --- a/zellij-server/src/tab/unit/tab_tests.rs +++ b/zellij-server/src/tab/unit/tab_tests.rs @@ -192,6 +192,25 @@ fn create_new_tab_with_cell_size( tab } +#[test] +fn write_to_suppressed_pane() { + let size = Size { + cols: 121, + rows: 20, + }; + let mut tab = create_new_tab(size); + tab.vertical_split(PaneId::Terminal(2), 1); + + // Suppress pane 2 and remove it from active panes + tab.suppress_active_pane(PaneId::Terminal(2), 1); + tab.tiled_panes.remove_pane(PaneId::Terminal(2)); + + // Make sure it's suppressed now + tab.suppressed_panes.get(&PaneId::Terminal(2)).unwrap(); + // Write content to it + tab.write_to_pane_id(vec![34, 127, 31, 82, 17, 182], PaneId::Terminal(2)); +} + #[test] fn split_panes_vertically() { let size = Size {