From ea4587a3b8b824f3090203e438458ad9b627fb19 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Thu, 23 Mar 2023 22:41:24 +1100 Subject: [PATCH] move some methods --- pkg/gui/context_config.go | 17 ----------------- pkg/gui/layout.go | 19 ++++++++++++++++++- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/pkg/gui/context_config.go b/pkg/gui/context_config.go index a81e01bf5..748482a35 100644 --- a/pkg/gui/context_config.go +++ b/pkg/gui/context_config.go @@ -1,7 +1,6 @@ package gui import ( - "github.com/jesseduffield/generics/slices" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/types" ) @@ -22,16 +21,6 @@ func OnFocusWrapper(f func() error) func(opts types.OnFocusOpts) error { } } -func (gui *Gui) popupViewNames() []string { - popups := slices.Filter(gui.State.Contexts.Flatten(), func(c types.Context) bool { - return c.GetKind() == types.PERSISTENT_POPUP || c.GetKind() == types.TEMPORARY_POPUP - }) - - return slices.Map(popups, func(c types.Context) string { - return c.GetViewName() - }) -} - func (gui *Gui) defaultSideContext() types.Context { if gui.State.Modes.Filtering.Active() { return gui.State.Contexts.LocalCommits @@ -39,9 +28,3 @@ func (gui *Gui) defaultSideContext() types.Context { return gui.State.Contexts.Files } } - -func (gui *Gui) TransientContexts() []types.Context { - return slices.Filter(gui.State.Contexts.Flatten(), func(context types.Context) bool { - return context.IsTransient() - }) -} diff --git a/pkg/gui/layout.go b/pkg/gui/layout.go index 2f51b7432..30177ac2f 100644 --- a/pkg/gui/layout.go +++ b/pkg/gui/layout.go @@ -4,6 +4,7 @@ import ( "github.com/jesseduffield/generics/slices" "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/gui/context" + "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/theme" ) @@ -95,7 +96,7 @@ func (gui *Gui) layout(g *gocui.Gui) error { gui.Views.Tooltip.Visible = gui.Views.Menu.Visible && gui.Views.Tooltip.Buffer() != "" - for _, context := range gui.TransientContexts() { + for _, context := range gui.transientContexts() { view, err := gui.g.View(context.GetViewName()) if err != nil && !gocui.IsUnknownView(err) { return err @@ -188,6 +189,16 @@ func (gui *Gui) onInitialViewsCreationForRepo() error { return gui.loadNewRepo() } +func (gui *Gui) popupViewNames() []string { + popups := slices.Filter(gui.State.Contexts.Flatten(), func(c types.Context) bool { + return c.GetKind() == types.PERSISTENT_POPUP || c.GetKind() == types.TEMPORARY_POPUP + }) + + return slices.Map(popups, func(c types.Context) string { + return c.GetViewName() + }) +} + func (gui *Gui) onInitialViewsCreation() error { // now we order the views (in order of bottom first) for _, view := range gui.orderedViews() { @@ -266,3 +277,9 @@ func (gui *Gui) onViewFocusLost(oldView *gocui.View) error { return nil } + +func (gui *Gui) transientContexts() []types.Context { + return slices.Filter(gui.State.Contexts.Flatten(), func(context types.Context) bool { + return context.IsTransient() + }) +}