1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-10 23:57:43 +02:00

hide commit files view upon losing focus because you probably don't want it lingering anyway

This commit is contained in:
Jesse Duffield 2021-04-01 00:24:57 +11:00
parent af09223dd5
commit 872cf0d726
2 changed files with 14 additions and 1 deletions

View File

@ -485,7 +485,7 @@ func (gui *Gui) returnFromContext() error {
func (gui *Gui) deactivateContext(c Context) error { func (gui *Gui) deactivateContext(c Context) error {
// if we are the kind of context that is sent to back upon deactivation, we should do that // if we are the kind of context that is sent to back upon deactivation, we should do that
if c.GetKind() == TEMPORARY_POPUP || c.GetKind() == PERSISTENT_POPUP { if c.GetKind() == TEMPORARY_POPUP || c.GetKind() == PERSISTENT_POPUP || c.GetKey() == COMMIT_FILES_CONTEXT_KEY {
_, _ = gui.g.SetViewOnBottom(c.GetViewName()) _, _ = gui.g.SetViewOnBottom(c.GetViewName())
} }
@ -682,6 +682,13 @@ func (gui *Gui) onViewFocusLost(v *gocui.View, newView *gocui.View) error {
} }
} }
if v.Name() == "commitFiles" && newView.Name() != "main" && newView.Name() != "secondary" {
gui.resetWindowForView("commitFiles")
if err := gui.deactivateContext(gui.Contexts.CommitFiles.Context); err != nil {
return err
}
}
return nil return nil
} }

View File

@ -40,3 +40,9 @@ func (gui *Gui) resetWindowForView(viewName string) {
// we assume here that the window contains as its default view a view with the same name as the window // we assume here that the window contains as its default view a view with the same name as the window
gui.State.WindowViewNameMap[window] = window gui.State.WindowViewNameMap[window] = window
} }
func (gui *Gui) renderWindow(window string) error {
viewName := gui.getViewNameForWindow(window)
gui.Log.Warn(viewName)
return gui.rerenderView(viewName)
}