1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-30 03:23:08 +03:00

add contexts to views

This commit is contained in:
Jesse Duffield
2019-11-16 12:41:04 +11:00
parent 44bbc106a9
commit 7e0a8f235e
13 changed files with 531 additions and 486 deletions

View File

@ -167,7 +167,7 @@ type guiState struct {
Updating bool
Panels *panelStates
WorkingTreeState string // one of "merging", "rebasing", "normal"
Context string // important not to set this value directly but to use gui.changeContext("new context")
MainContext string // used to keep the main and secondary views' contexts in sync
CherryPickedCommits []*commands.Commit
SplitMainPanel bool
RetainOriginalDir bool
@ -315,11 +315,11 @@ func (gui *Gui) onFocusLost(v *gocui.View, newView *gocui.View) error {
}
case "main":
// if we have lost focus to a first-class panel, we need to do some cleanup
if err := gui.changeContext("normal"); err != nil {
if err := gui.changeMainViewsContext("normal"); err != nil {
return err
}
case "commitFiles":
if gui.State.Context != "patch-building" {
if gui.State.MainContext != "patch-building" {
if _, err := gui.g.SetViewOnBottom(v.Name()); err != nil {
return err
}
@ -582,7 +582,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
}
// doing this here because it'll only happen once
if err := gui.loadNewRepo(); err != nil {
if err := gui.onInitialViewsCreation(); err != nil {
return err
}
}
@ -627,6 +627,14 @@ func (gui *Gui) layout(g *gocui.Gui) error {
return gui.resizeCurrentPopupPanel(g)
}
func (gui *Gui) onInitialViewsCreation() error {
if err := gui.changeMainViewsContext("normal"); err != nil {
return err
}
return gui.loadNewRepo()
}
func (gui *Gui) loadNewRepo() error {
gui.Updater.CheckForNewUpdate(gui.onBackgroundUpdateCheckFinish, false)
if err := gui.updateRecentRepoList(); err != nil {