From a553a2d8ad6e4ed0ba2aafa940a816afb8056fc6 Mon Sep 17 00:00:00 2001 From: Aram Drevekenin Date: Thu, 24 Oct 2024 09:42:15 +0200 Subject: [PATCH] fix(terminal): recover from partial line drop (#3695) --- zellij-server/src/panes/grid.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/zellij-server/src/panes/grid.rs b/zellij-server/src/panes/grid.rs index 8a603f4b98..b5666f87e7 100644 --- a/zellij-server/src/panes/grid.rs +++ b/zellij-server/src/panes/grid.rs @@ -705,9 +705,17 @@ impl Grid { let line_to_push_up = if line_to_push_up.is_canonical { line_to_push_up } else { - let mut last_line_above = self.lines_above.pop_back().unwrap(); - last_line_above.append(&mut line_to_push_up.columns); - last_line_above + match self.lines_above.pop_back() { + Some(mut last_line_above) => { + last_line_above.append(&mut line_to_push_up.columns); + last_line_above + }, + None => { + // in this case, this line was not canonical but its beginning line was + // dropped out of scope, so we make it canonical and push it up + line_to_push_up.canonical() + }, + } }; let dropped_line_width =