Revert "fix panic on closing a tab"
This reverts commit d7feb56cbe
.
This commit introduced a regression in which upon closing any but the
last tab caused an out of range panic would occur.
Steps to reproduce
- open a tab
- open another tab
- close the first tab
Fixes: https://todo.sr.ht/~rjarry/aerc/58
Reported-by: akspecs <akspecs@gmail.com>
Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
parent
5e600d7ab4
commit
f642fc9038
1 changed files with 2 additions and 6 deletions
|
@ -74,13 +74,10 @@ func (tabs *Tabs) invalidateChild(d Drawable) {
|
||||||
|
|
||||||
func (tabs *Tabs) Remove(content Drawable) {
|
func (tabs *Tabs) Remove(content Drawable) {
|
||||||
indexToRemove := -1
|
indexToRemove := -1
|
||||||
removeTab := func() {}
|
|
||||||
for i, tab := range tabs.Tabs {
|
for i, tab := range tabs.Tabs {
|
||||||
if tab.Content == content {
|
if tab.Content == content {
|
||||||
removeTab = func() {
|
|
||||||
tabs.Tabs = append(tabs.Tabs[:i], tabs.Tabs[i+1:]...)
|
tabs.Tabs = append(tabs.Tabs[:i], tabs.Tabs[i+1:]...)
|
||||||
tabs.removeHistory(i)
|
tabs.removeHistory(i)
|
||||||
}
|
|
||||||
indexToRemove = i
|
indexToRemove = i
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -102,7 +99,6 @@ func (tabs *Tabs) Remove(content Drawable) {
|
||||||
// selected tab is now one to the left of where it was
|
// selected tab is now one to the left of where it was
|
||||||
tabs.Selected--
|
tabs.Selected--
|
||||||
}
|
}
|
||||||
removeTab()
|
|
||||||
tabs.TabStrip.Invalidate()
|
tabs.TabStrip.Invalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue