From 39c8577074166d9f2dca2d29515915fc47d0513c Mon Sep 17 00:00:00 2001 From: Cristian Betivu Date: Tue, 15 Jun 2021 19:58:43 +0200 Subject: [PATCH] Use static context --- pkg/gui/menu_panel.go | 2 -- pkg/gui/view_helpers.go | 15 ++++----------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/pkg/gui/menu_panel.go b/pkg/gui/menu_panel.go index 91071f200..fcb1f7a7b 100644 --- a/pkg/gui/menu_panel.go +++ b/pkg/gui/menu_panel.go @@ -74,13 +74,11 @@ func (gui *Gui) createMenu(title string, items []*menuItem, createMenuOptions cr list := utils.RenderDisplayStrings(stringArrays) - parentView := gui.g.CurrentView() x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(false, list) menuView, _ := gui.g.SetView("menu", x0, y0, x1, y1, 0) menuView.Title = title menuView.FgColor = theme.GocuiDefaultTextColor menuView.ContainsList = true - menuView.ParentView = parentView menuView.Clear() menuView.SetOnSelectItem(gui.onSelectItemWrapper(func(selectedLine int) error { return nil diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go index d85d4e3a7..429f47a11 100644 --- a/pkg/gui/view_helpers.go +++ b/pkg/gui/view_helpers.go @@ -394,15 +394,8 @@ func (gui *Gui) pageDelta(view *gocui.View) int { } func getTabbedView(gui *Gui) *gocui.View { - v := gui.g.CurrentView() - if v == nil { - return nil - } - // if the action is invoked via the Options menu, - // we need to execute it against the parent view - if v.Name() == "menu" { - v = v.ParentView - } - - return v + // It safe assumption that only static contexts have tabs + context := gui.currentStaticContext() + view, _ := gui.g.View(context.GetViewName()) + return view }