aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authordelitako <delitako@delitako.xyz>2024-01-25 22:50:14 -0600
committerRobin Jarry <robin@jarry.cc>2024-01-26 20:27:08 +0100
commit936d519a67301bd78a4d737dc47234e3769e639f (patch)
tree701dc21c0551d4f020cb1c339ba0270c1525c2a7 /app
parent58585e0a8e264f7a5500b3f24b0b319d59f36882 (diff)
downloadaerc-936d519a67301bd78a4d737dc47234e3769e639f.tar.gz
aerc-936d519a67301bd78a4d737dc47234e3769e639f.zip
tabs: optimize switching by offsets
I imagine no sane user requires aerc to correctly handle commands like `:next-tab 1000000000`, but I tried anyway and it froze aerc while also eating up many GBs of system memory. This behavior is not ideal, so I improved it. This commit adds functions for selecting a tab at an offset from the currently-selected tab and changes the next-tab, prev-tab, and change-tab commands to use these functions instead of looping. Signed-off-by: delitako <delitako@delitako.xyz> Tested-by: Thomas Böhler <witcher@wiredspace.de> Reviewed-by: Thomas Böhler <witcher@wiredspace.de> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'app')
-rw-r--r--app/aerc.go4
-rw-r--r--app/app.go1
2 files changed, 5 insertions, 0 deletions
diff --git a/app/aerc.go b/app/aerc.go
index c7307540..31d3a44b 100644
--- a/app/aerc.go
+++ b/app/aerc.go
@@ -525,6 +525,10 @@ func (aerc *Aerc) SelectTabIndex(index int) bool {
return ok
}
+func (aerc *Aerc) SelectTabAtOffset(offset int) {
+ aerc.tabs.SelectOffset(offset)
+}
+
func (aerc *Aerc) TabNames() []string {
return aerc.tabs.Names()
}
diff --git a/app/app.go b/app/app.go
index ea4e4d26..ca9c59bb 100644
--- a/app/app.go
+++ b/app/app.go
@@ -55,6 +55,7 @@ func SelectPreviousTab() bool { return aerc.SelectPrev
func SelectedTab() *ui.Tab { return aerc.SelectedTab() }
func SelectedTabContent() ui.Drawable { return aerc.SelectedTabContent() }
func SelectTabIndex(index int) bool { return aerc.SelectTabIndex(index) }
+func SelectTabAtOffset(offset int) { aerc.SelectTabAtOffset(offset) }
func RemoveTab(tab ui.Drawable, closeContent bool) { aerc.RemoveTab(tab, closeContent) }
func NewTab(clickable ui.Drawable, name string) *ui.Tab { return aerc.NewTab(clickable, name) }
func ReplaceTab(tabSrc ui.Drawable, tabTarget ui.Drawable, name string, closeSrc bool) {