diff --git a/pkg/gui/controllers/helpers/window_helper.go b/pkg/gui/controllers/helpers/window_helper.go index efe84c398..4bdd7a889 100644 --- a/pkg/gui/controllers/helpers/window_helper.go +++ b/pkg/gui/controllers/helpers/window_helper.go @@ -92,7 +92,7 @@ func (self *WindowHelper) MoveToTopOfWindow(context types.Context) { topView := self.TopViewInWindow(window) - if view.Name() != topView.Name() { + if topView != nil && view.Name() != topView.Name() { if err := self.c.GocuiGui().SetViewOnTopOf(view.Name(), topView.Name()); err != nil { self.c.Log.Error(err) } @@ -106,7 +106,7 @@ func (self *WindowHelper) TopViewInWindow(windowName string) *gocui.View { // The views list is ordered highest-last, so we're grabbing the last view of the window var topView *gocui.View for _, currentView := range self.c.GocuiGui().Views() { - if lo.Contains(viewNamesInWindow, currentView.Name()) { + if lo.Contains(viewNamesInWindow, currentView.Name()) && currentView.Visible { topView = currentView } } diff --git a/pkg/gui/main_panels.go b/pkg/gui/main_panels.go index d3418b628..3dee86f1b 100644 --- a/pkg/gui/main_panels.go +++ b/pkg/gui/main_panels.go @@ -39,12 +39,8 @@ func (gui *Gui) moveMainContextToTop(context types.Context) { view := context.GetView() topView := gui.helpers.Window.TopViewInWindow(context.GetWindowName()) - if topView == nil { - gui.Log.Error("unexpected: topView is nil") - return - } - if topView != view { + if topView != nil && topView != view { // We need to copy the content to avoid a flicker effect: If we're flicking // through files in the files panel, we use a different view to render the // files vs the directories, and if you select dir A, then file B, then dir