From f1d7f59e497a2da9066494d04f26e1ff00a0e4ee Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sat, 3 Apr 2021 13:43:43 +1100 Subject: switching repos without restarting the gui --- pkg/gui/layout.go | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'pkg/gui/layout.go') diff --git a/pkg/gui/layout.go b/pkg/gui/layout.go index 32ad1de85..a60a137af 100644 --- a/pkg/gui/layout.go +++ b/pkg/gui/layout.go @@ -216,11 +216,6 @@ func (gui *Gui) layout(g *gocui.Gui) error { } v.Frame = false v.FgColor = theme.OptionsColor - - // doing this here because it'll only happen once - if err := gui.onInitialViewsCreation(); err != nil { - return err - } } // this view takes up one character. Its only purpose is to show the slash when searching @@ -271,6 +266,14 @@ func (gui *Gui) layout(g *gocui.Gui) error { gui.State.OldInformation = informationStr } + if !gui.State.ViewsSetup { + if err := gui.onInitialViewsCreation(); err != nil { + return err + } + + gui.State.ViewsSetup = true + } + if gui.g.CurrentView() == nil { initialContext := gui.Contexts.Files if gui.State.Modes.Filtering.Active() { @@ -323,8 +326,13 @@ func (gui *Gui) layout(g *gocui.Gui) error { func (gui *Gui) onInitialViewsCreation() error { gui.setInitialViewContexts() - // add tabs to views + // hide any popup views. This only applies when we've just switched repos + for _, viewName := range gui.popupViewNames() { + _, _ = gui.g.SetViewOnBottom(viewName) + } + gui.g.Mutexes.ViewsMutex.Lock() + // add tabs to views for _, view := range gui.g.Views() { tabs := gui.viewTabNames(view.Name()) if len(tabs) == 0 { -- cgit v1.2.3