mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-24 05:36:19 +02:00
centralise setting of main views context
This commit is contained in:
parent
2488e0044d
commit
f0c3d3fc4d
@ -209,7 +209,6 @@ func (gui *Gui) enterCommitFile(selectedLineIdx int) error {
|
||||
}
|
||||
}
|
||||
|
||||
gui.changeMainViewsContext("patch-building") // TODO: bring into context code
|
||||
if err := gui.switchContext(gui.Contexts.PatchBuilding.Context); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package gui
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/jesseduffield/gocui"
|
||||
)
|
||||
|
||||
@ -104,6 +106,10 @@ func (gui *Gui) switchContext(c Context) error {
|
||||
gui.State.ContextStack = append(gui.State.ContextStack, c)
|
||||
}
|
||||
|
||||
if c.GetViewName() == "main" {
|
||||
gui.changeMainViewsContext(c.GetKey())
|
||||
}
|
||||
|
||||
return gui.activateContext(c)
|
||||
})
|
||||
|
||||
@ -422,6 +428,8 @@ func (gui *Gui) changeMainViewsContext(context string) {
|
||||
case "normal", "patch-building", "staging", "merging":
|
||||
gui.getMainView().Context = context
|
||||
gui.getSecondaryView().Context = context
|
||||
default:
|
||||
panic(fmt.Sprintf("unknown context for main: %s", context))
|
||||
}
|
||||
|
||||
gui.State.MainContext = context
|
||||
|
@ -165,7 +165,6 @@ func (gui *Gui) enterFile(forceSecondaryFocused bool, selectedLineIdx int) error
|
||||
if file.HasMergeConflicts {
|
||||
return gui.createErrorPanel(gui.Tr.SLocalize("FileStagingRequirements"))
|
||||
}
|
||||
gui.changeMainViewsContext("staging") // TODO: move into context code
|
||||
gui.switchContext(gui.Contexts.Staging.Context)
|
||||
|
||||
return gui.refreshStagingPanel(forceSecondaryFocused, selectedLineIdx) // TODO: check if this is broken, try moving into context code
|
||||
@ -577,7 +576,6 @@ func (gui *Gui) handleSwitchToMerge() error {
|
||||
if !file.HasInlineMergeConflicts {
|
||||
return gui.createErrorPanel(gui.Tr.SLocalize("FileNoMergeCons"))
|
||||
}
|
||||
gui.changeMainViewsContext("merging") // TODO: move into context code
|
||||
return gui.switchContext(gui.Contexts.Merging.Context)
|
||||
}
|
||||
|
||||
|
@ -343,8 +343,6 @@ func (gui *Gui) onInitialViewsCreation() error {
|
||||
return err
|
||||
}
|
||||
|
||||
gui.changeMainViewsContext("normal")
|
||||
|
||||
if gui.showRecentRepos {
|
||||
if err := gui.handleCreateRecentReposMenu(); err != nil {
|
||||
return err
|
||||
|
@ -325,7 +325,6 @@ func (gui *Gui) handleToggleSelectHunk(g *gocui.Gui, v *gocui.View) error {
|
||||
}
|
||||
|
||||
func (gui *Gui) handleEscapeLineByLinePanel() {
|
||||
gui.changeMainViewsContext("normal")
|
||||
gui.State.Panels.LineByLine = nil
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user