]> git.lizzy.rs Git - micro.git/commitdiff
implemented circular tab movement (#1619)
author2pac <tarasyaremabcn@gmail.com>
Fri, 17 Apr 2020 17:42:48 +0000 (19:42 +0200)
committerGitHub <noreply@github.com>
Fri, 17 Apr 2020 17:42:48 +0000 (13:42 -0400)
Co-authored-by: 2pac <tarasyarema@pm.me>
internal/action/actions.go

index ed4151f87df32b87215d005439f99ec15b92110b..fd363281560513910c2009eb55b1ed77af413cbc 100644 (file)
@@ -1447,8 +1447,9 @@ func (h *BufPane) AddTab() bool {
 
 // PreviousTab switches to the previous tab in the tab list
 func (h *BufPane) PreviousTab() bool {
-       a := Tabs.Active()
-       Tabs.SetActive(util.Clamp(a-1, 0, len(Tabs.List)-1))
+       tabsLen := len(Tabs.List)
+       a := Tabs.Active() + tabsLen 
+       Tabs.SetActive((a - 1) % tabsLen)
 
        return true
 }
@@ -1456,7 +1457,8 @@ func (h *BufPane) PreviousTab() bool {
 // NextTab switches to the next tab in the tab list
 func (h *BufPane) NextTab() bool {
        a := Tabs.Active()
-       Tabs.SetActive(util.Clamp(a+1, 0, len(Tabs.List)-1))
+       Tabs.SetActive((a + 1) % len(Tabs.List))
+
        return true
 }