diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index bb2c5a59..a5eb08b1 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -131,14 +131,8 @@ type guiState struct { // NewGui builds a new gui handler func NewGui(log *logrus.Entry, dockerCommand *commands.DockerCommand, oSCommand *commands.OSCommand, tr *i18n.TranslationSet, config *config.AppConfig, errorChan chan error) (*Gui, error) { - previousView := "containers" - if dockerCommand.InDockerComposeProject { - previousView = "services" - } - initialState := guiState{ - PreviousView: previousView, - Platform: *oSCommand.Platform, + Platform: *oSCommand.Platform, Panels: &panelStates{ Services: &servicePanelState{SelectedLine: -1, ContextIndex: 0}, Containers: &containerPanelState{SelectedLine: -1, ContextIndex: 0}, @@ -390,3 +384,10 @@ func (gui *Gui) shouldRefresh(key string) bool { gui.State.Panels.Main.ObjectKey = key return true } + +func (gui *Gui) initiallyFocusedViewName() string { + if gui.DockerCommand.InDockerComposeProject { + return "services" + } + return "containers" +} diff --git a/pkg/gui/layout.go b/pkg/gui/layout.go index a18ed005..71fb7e6a 100644 --- a/pkg/gui/layout.go +++ b/pkg/gui/layout.go @@ -275,7 +275,11 @@ func (gui *Gui) layout(g *gocui.Gui) error { if gui.g.CurrentView() == nil { v, err := gui.g.View(gui.State.PreviousView) if err != nil { - v = gui.getServicesView() + viewName := gui.initiallyFocusedViewName() + v, err = gui.g.View(viewName) + if err != nil { + return err + } } if err := gui.switchFocus(gui.g, nil, v); err != nil {