fix: move focused_tab if >= removed index

If the focused tab index is before the removed tab index,
then it must not change, if it is equal or after, because
all the elements are moved to the left, the focused tab
index must be decremented with 0 as minimum.
This commit is contained in:
edouardparis 2025-07-24 10:49:58 +02:00
parent a242834bff
commit 88966c2b09

View File

@ -71,13 +71,11 @@ impl Pane {
return None;
}
let tab = self.tabs.remove(i);
self.focused_tab = if self.tabs.is_empty() {
0
} else if i < self.tabs.len() - 1 {
i
} else {
self.tabs.len() - 1
};
if self.focused_tab >= i {
self.focused_tab = self.focused_tab.saturating_sub(1);
}
Some(tab)
}