Skip to content

Commit

Permalink
fix(plugins): properly focus pane after tab was closed (zellij-org#3797)
Browse files Browse the repository at this point in the history
* fix(plugins): properly focus pane after tab was closed

* style(fmt): rustfmt
  • Loading branch information
imsnif committed Dec 31, 2024
1 parent c23758e commit f5ec873
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions zellij-server/src/screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2087,15 +2087,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);
Expand Down Expand Up @@ -2407,11 +2408,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);
Expand Down

0 comments on commit f5ec873

Please sign in to comment.