aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2024-11-21 16:26:11 +0100
committerGitHub <noreply@github.com>2024-11-21 16:26:11 +0100
commit7ef4e82d7036fbd8e5064f4b58bd29bf20865731 (patch)
treecb51cef11632194f87d4886901dd4ac12577f0b3
parentchore(repo): fix typo in lock file (diff)
downloadsl0ppij-7ef4e82d7036fbd8e5064f4b58bd29bf20865731.tar.gz
sl0ppij-7ef4e82d7036fbd8e5064f4b58bd29bf20865731.tar.xz
sl0ppij-7ef4e82d7036fbd8e5064f4b58bd29bf20865731.zip
fix(plugins): properly focus pane after tab was closed (#3797)
* fix(plugins): properly focus pane after tab was closed * style(fmt): rustfmt
-rw-r--r--zellij-server/src/screen.rs20
1 files changed, 12 insertions, 8 deletions
diff --git a/zellij-server/src/screen.rs b/zellij-server/src/screen.rs
index e04ff35c..66065508 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);