From b6cc1c949221810966b3c3cb4a386dc6c7faa023 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Mon, 5 Apr 2021 00:44:13 +1000 Subject: [PATCH] small refactor --- pkg/gui/context.go | 9 ++------- pkg/gui/global_handlers.go | 4 ++-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/pkg/gui/context.go b/pkg/gui/context.go index 94e227d0e..67ded3060 100644 --- a/pkg/gui/context.go +++ b/pkg/gui/context.go @@ -769,13 +769,8 @@ func (gui *Gui) contextForContextKey(contextKey ContextKey) (Context, bool) { return nil, false } -func (gui *Gui) rerenderView(viewName string) error { - v, err := gui.g.View(viewName) - if err != nil { - return nil - } - - contextKey := ContextKey(v.Context) +func (gui *Gui) rerenderView(view *gocui.View) error { + contextKey := ContextKey(view.Context) context := gui.mustContextForContextKey(contextKey) return context.HandleRender() diff --git a/pkg/gui/global_handlers.go b/pkg/gui/global_handlers.go index d4e0923b7..25aafa588 100644 --- a/pkg/gui/global_handlers.go +++ b/pkg/gui/global_handlers.go @@ -13,8 +13,8 @@ import ( // these views need to be re-rendered when the screen mode changes. The commits view, // for example, will show authorship information in half and full screen mode. func (gui *Gui) rerenderViewsWithScreenModeDependentContent() error { - for _, viewName := range []string{"branches", "commits"} { - if err := gui.rerenderView(viewName); err != nil { + for _, view := range []*gocui.View{gui.Views.Branches, gui.Views.Commits} { + if err := gui.rerenderView(view); err != nil { return err } }