From f642fc90385ad521d32415b1fb5449becbe1a566 Mon Sep 17 00:00:00 2001 From: Moritz Poldrack Date: Mon, 18 Jul 2022 11:00:05 +0200 Subject: [PATCH] Revert "fix panic on closing a tab" This reverts commit d7feb56cbe7b81160b580ec2f5dcaef78c7a2230. 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 Signed-off-by: Moritz Poldrack Acked-by: Robin Jarry --- lib/ui/tab.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/ui/tab.go b/lib/ui/tab.go index 3be512f..a67bdab 100644 --- a/lib/ui/tab.go +++ b/lib/ui/tab.go @@ -74,13 +74,10 @@ func (tabs *Tabs) invalidateChild(d Drawable) { func (tabs *Tabs) Remove(content Drawable) { indexToRemove := -1 - removeTab := func() {} for i, tab := range tabs.Tabs { if tab.Content == content { - removeTab = func() { - tabs.Tabs = append(tabs.Tabs[:i], tabs.Tabs[i+1:]...) - tabs.removeHistory(i) - } + tabs.Tabs = append(tabs.Tabs[:i], tabs.Tabs[i+1:]...) + tabs.removeHistory(i) indexToRemove = i break } @@ -102,7 +99,6 @@ func (tabs *Tabs) Remove(content Drawable) { // selected tab is now one to the left of where it was tabs.Selected-- } - removeTab() tabs.TabStrip.Invalidate() }