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:
parent
a242834bff
commit
88966c2b09
@ -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)
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user