From 2002cb6579c46b6c62885f6df377b6c4a84d3714 Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Tue, 28 Jun 2016 21:29:46 -0400 Subject: [PATCH] Wrap around when using NextTab and PreviousTab Fixes #188 --- cmd/micro/bindings.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmd/micro/bindings.go b/cmd/micro/bindings.go index 21db8917..ba484adf 100644 --- a/cmd/micro/bindings.go +++ b/cmd/micro/bindings.go @@ -1112,6 +1112,7 @@ func (v *View) Quit() bool { return false } +// AddTab adds a new tab with an empty buffer func (v *View) AddTab() bool { tab := NewTabFromView(NewView(NewBuffer([]byte{}, ""))) tab.SetNum(len(tabs)) @@ -1127,16 +1128,22 @@ func (v *View) AddTab() bool { return true } +// PreviousTab switches to the previous tab in the tab list func (v *View) PreviousTab() bool { if curTab > 0 { curTab-- + } else if curTab == 0 { + curTab = len(tabs) - 1 } return false } +// NextTab switches to the next tab in the tab list func (v *View) NextTab() bool { if curTab < len(tabs)-1 { curTab++ + } else if curTab == len(tabs)-1 { + curTab = 0 } return false }