diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2022-03-26 14:44:30 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-03-26 18:00:46 +1100 |
commit | ad7703df65e09d23bb7e709ca9b22251673ac272 (patch) | |
tree | 67733bcebb87d6504c1d14368cb67a15acc36ecc /pkg/gui/context.go | |
parent | 13b90ac37f40baa648c25fab6d299ae0fa59118b (diff) |
show namesake for child views
Diffstat (limited to 'pkg/gui/context.go')
-rw-r--r-- | pkg/gui/context.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/pkg/gui/context.go b/pkg/gui/context.go index c02411640..c63defba4 100644 --- a/pkg/gui/context.go +++ b/pkg/gui/context.go @@ -151,8 +151,7 @@ func (gui *Gui) deactivateContext(c types.Context) error { if view != nil && (c.GetKind() == types.TEMPORARY_POPUP || c.GetKind() == types.PERSISTENT_POPUP || - c.GetKey() == context.COMMIT_FILES_CONTEXT_KEY || - c.GetKey() == context.SUB_COMMITS_CONTEXT_KEY) { + c.IsTransient()) { view.Visible = false } @@ -393,11 +392,7 @@ func (gui *Gui) onViewFocusLost(oldView *gocui.View, newView *gocui.View) error _ = oldView.SetOriginX(0) if !lo.Contains([]*gocui.View{gui.Views.Main, gui.Views.Secondary, gui.Views.Search}, newView) { - transientContexts := slices.Filter(gui.State.Contexts.Flatten(), func(context types.Context) bool { - return context.IsTransient() - }) - - for _, context := range transientContexts { + for _, context := range gui.TransientContexts() { if oldView.Name() == context.GetViewName() { if err := gui.deactivateContext(context); err != nil { return err @@ -409,6 +404,12 @@ func (gui *Gui) onViewFocusLost(oldView *gocui.View, newView *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() + }) +} + // changeContext is a helper function for when we want to change a 'main' context // which currently just means a context that affects both the main and secondary views // other views can have their context changed directly but this function helps |