From afd092c272c3493ede2036be8ab89e42957dd045 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sun, 17 May 2020 21:54:51 +1000 Subject: [PATCH] softcode cyclable views --- pkg/gui/arrangement.go | 2 +- pkg/gui/view_helpers.go | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/gui/arrangement.go b/pkg/gui/arrangement.go index aaeee0a7f0e..6ce9b79078f 100644 --- a/pkg/gui/arrangement.go +++ b/pkg/gui/arrangement.go @@ -172,7 +172,7 @@ func (gui *Gui) currentCyclableViewName() string { if currView != nil { viewName := currView.Name() usePreviousView := true - for _, view := range cyclableViews { + for _, view := range gui.getCyclableViews() { if view == viewName { currentCyclebleView = viewName usePreviousView = false diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go index 06479d1e9ab..29921059e2b 100644 --- a/pkg/gui/view_helpers.go +++ b/pkg/gui/view_helpers.go @@ -12,7 +12,9 @@ import ( "github.com/spkg/bom" ) -var cyclableViews = []string{"status", "files", "branches", "commits", "stash"} +func (gui *Gui) getCyclableViews() []string { + return []string{"status", "files", "branches", "commits", "stash"} +} // models/views that we can refresh const ( @@ -140,6 +142,7 @@ func (gui *Gui) refreshSidePanels(options refreshOptions) error { func (gui *Gui) nextView(g *gocui.Gui, v *gocui.View) error { var focusedViewName string + cyclableViews := gui.getCyclableViews() if v == nil || v.Name() == cyclableViews[len(cyclableViews)-1] { focusedViewName = cyclableViews[0] } else { @@ -176,6 +179,7 @@ func (gui *Gui) nextView(g *gocui.Gui, v *gocui.View) error { } func (gui *Gui) previousView(g *gocui.Gui, v *gocui.View) error { + cyclableViews := gui.getCyclableViews() var focusedViewName string if v == nil || v.Name() == cyclableViews[0] { focusedViewName = cyclableViews[len(cyclableViews)-1]