From 51b608953739e1cf8fbd1efe8a617807f26d2824 Mon Sep 17 00:00:00 2001 From: Aram Drevekenin Date: Thu, 21 Nov 2024 14:30:50 +0100 Subject: [PATCH 1/2] fix(plugins): properly focus pane after tab was closed --- zellij-server/src/screen.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/zellij-server/src/screen.rs b/zellij-server/src/screen.rs index e04ff35c49..e7406bf905 100644 --- a/zellij-server/src/screen.rs +++ b/zellij-server/src/screen.rs @@ -2090,15 +2090,16 @@ impl Screen { .tabs .iter() .find(|(_tab_index, tab)| tab.has_pane_with_pid(&pane_id)) - .map(|(tab_index, _tab)| *tab_index); + .map(|(_tab_index, tab)| tab.position); match tab_index { Some(tab_index) => { self.go_to_tab(tab_index + 1, client_id)?; self.tabs - .get_mut(&tab_index) - .with_context(err_context)? - .focus_pane_with_id(pane_id, should_float_if_hidden, client_id) - .context("failed to focus pane with id")?; + .iter_mut() + .find(|(_, t)| t.position == tab_index) + .map(|(_, t)| t.focus_pane_with_id(pane_id, should_float_if_hidden, client_id)) + .with_context(err_context) + .non_fatal(); }, None => { log::error!("Could not find pane with id: {:?}", pane_id); @@ -2410,11 +2411,14 @@ impl Screen { .tabs .iter() .find(|(_tab_index, tab)| tab.has_pane_with_pid(&pane_id)) - .map(|(tab_index, _tab)| *tab_index); + .map(|(_tab_index, tab)| tab.position); match tab_index { Some(tab_index) => { - let tab = self.tabs.get_mut(&tab_index).with_context(err_context)?; - suppress_pane(tab, pane_id, new_pane_id); + if let Some(tab) = self.tabs + .iter_mut() + .find(|(_, t)| t.position == tab_index) { + suppress_pane(tab.1, pane_id, new_pane_id); + } }, None => { log::error!("Could not find pane with id: {:?}", pane_id); From 37811dad9a1d674316d9d30545ca9af5f5886085 Mon Sep 17 00:00:00 2001 From: Aram Drevekenin Date: Thu, 21 Nov 2024 14:33:24 +0100 Subject: [PATCH 2/2] style(fmt): rustfmt --- zellij-server/src/screen.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zellij-server/src/screen.rs b/zellij-server/src/screen.rs index e7406bf905..66065508cf 100644 --- a/zellij-server/src/screen.rs +++ b/zellij-server/src/screen.rs @@ -2414,10 +2414,10 @@ impl Screen { .map(|(_tab_index, tab)| tab.position); match tab_index { Some(tab_index) => { - if let Some(tab) = self.tabs - .iter_mut() - .find(|(_, t)| t.position == tab_index) { - suppress_pane(tab.1, pane_id, new_pane_id); + if let Some(tab) = + self.tabs.iter_mut().find(|(_, t)| t.position == tab_index) + { + suppress_pane(tab.1, pane_id, new_pane_id); } }, None => {