Skip to content

Commit

Permalink
fix: update pane index when moving panes in same tab
Browse files Browse the repository at this point in the history
  • Loading branch information
scauligi committed Aug 25, 2024
1 parent 30345b3 commit 96b5354
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion mux/src/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub trait Domain: Downcast + Send + Sync {
None => anyhow::bail!("Invalid tab id {}", tab),
};

let pane_index = match tab
let mut pane_index = match tab
.iter_panes_ignoring_zoom()
.iter()
.find(|p| p.pane.pane_id() == pane_id)
Expand Down Expand Up @@ -119,6 +119,18 @@ pub trait Domain: Downcast + Send + Sync {
anyhow::anyhow!("pane {} not found in its containing tab!?", src_pane_id)
})?;

// May need to update pane_index if src_pane was also in the same tab
if src_tab.tab_id() == tab.tab_id() {
pane_index = match tab
.iter_panes_ignoring_zoom()
.iter()
.find(|p| p.pane.pane_id() == pane_id)
{
Some(p) => p.index,
None => anyhow::bail!("invalid pane id {}", pane_id),
};
}

if src_tab.is_dead() {
mux.remove_tab(src_tab.tab_id());
}
Expand Down

0 comments on commit 96b5354

Please sign in to comment.