summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2023-03-08 18:43:26 +0100
committerGitHub <noreply@github.com>2023-03-08 18:43:26 +0100
commitae29eb5b47c2d1f64745db6fa6bf8591e52db0cc (patch)
tree61cf0679ef93cbac7bc92076f07729845764f205
parenta2609296acbd4ac5a3eb56d95add8059b8341fe4 (diff)
fix(screen): hold and applylayout races (#2251)
* fix(screen): log error instead of crashing when unable to find tab id * style(fmt): rustfmt
-rw-r--r--zellij-server/src/screen.rs18
1 files changed, 12 insertions, 6 deletions
diff --git a/zellij-server/src/screen.rs b/zellij-server/src/screen.rs
index 490995122..a2fa3e506 100644
--- a/zellij-server/src/screen.rs
+++ b/zellij-server/src/screen.rs
@@ -988,6 +988,12 @@ impl Screen {
tab_index: usize,
client_id: ClientId,
) -> Result<()> {
+ if self.tabs.get(&tab_index).is_none() {
+ // TODO: we should prevent this situation with a UI - eg. cannot close tabs with a
+ // pending state
+ log::error!("Tab with index {tab_index} not found. Cannot apply layout!");
+ return Ok(());
+ }
let client_id = if self.get_active_tab(client_id).is_ok() {
client_id
} else if let Some(first_client_id) = self.get_first_client_id() {
@@ -1941,12 +1947,12 @@ pub(crate) fn screen_thread_main(
run_command
));
},
- (_, Some(tab_index)) => {
- let tab = screen
- .tabs
- .get_mut(&tab_index)
- .context("couldn't find tab with index {tab_index}")?;
- tab.hold_pane(id, exit_status, is_first_run, run_command);
+ (_, Some(tab_index)) => match screen.tabs.get_mut(&tab_index) {
+ Some(tab) => tab.hold_pane(id, exit_status, is_first_run, run_command),
+ None => log::warn!(
+ "Tab with index {tab_index} not found. Cannot hold pane with id {:?}",
+ id
+ ),
},
_ => {
for tab in screen.tabs.values_mut() {