1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-02-09 13:47:11 +02:00

better logic for taking focus away from popup panels

This commit is contained in:
Jesse Duffield 2020-08-18 08:04:15 +10:00
parent 119d5be1a4
commit a12d18146c
5 changed files with 8 additions and 28 deletions

View File

@ -167,19 +167,7 @@ func (gui *Gui) prepareConfirmationPanel(currentView *gocui.View, title, prompt
return confirmationView, nil
}
func (gui *Gui) onNewPopupPanel() {
viewNames := []string{
"commitMessage",
"credentials",
"menu",
}
for _, viewName := range viewNames {
_, _ = gui.g.SetViewOnBottom(viewName) // TODO: investigate
}
}
func (gui *Gui) createPopupPanel(opts createPopupPanelOpts) error {
gui.onNewPopupPanel()
gui.g.Update(func(g *gocui.Gui) error {
// delete the existing confirmation panel if it exists
if view, _ := g.View("confirmation"); view != nil {

View File

@ -90,6 +90,13 @@ func (gui *Gui) switchContext(c Context) error {
// push onto stack
// if we are switching to a side context, remove all other contexts in the stack
if c.GetKind() == SIDE_CONTEXT {
for _, stackContext := range gui.State.ContextStack {
if stackContext.GetKey() != c.GetKey() {
if err := gui.deactivateContext(stackContext); err != nil {
return err
}
}
}
gui.State.ContextStack = []Context{c}
} else {
// TODO: think about other exceptional cases

View File

@ -97,7 +97,7 @@ type Gui struct {
// when lazygit is opened outside a git directory we want to open to the most
// recent repo with the recent repos popup showing
showRecentRepos bool
Contexts ContextTree
Contexts ContextTree
}
// for now the staging panel state, unlike the other panel states, is going to be

View File

@ -56,11 +56,6 @@ func (gui *Gui) previousSideWindow() error {
func (gui *Gui) goToSideWindow(sideViewName string) func(g *gocui.Gui, v *gocui.View) error {
return func(g *gocui.Gui, v *gocui.View) error {
err := gui.closePopupPanels()
if err != nil {
gui.Log.Error(err)
return nil
}
return gui.switchContextToView(sideViewName)
}
}

View File

@ -139,16 +139,6 @@ func (gui *Gui) refreshSidePanels(options refreshOptions) error {
return nil
}
func (gui *Gui) closePopupPanels() error {
gui.onNewPopupPanel()
err := gui.closeConfirmationPrompt(true)
if err != nil {
gui.Log.Error(err)
return err
}
return nil
}
func (gui *Gui) resetOrigin(v *gocui.View) error {
_ = v.SetCursor(0, 0)
return v.SetOrigin(0, 0)