mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-10 23:57:43 +02:00
ensure initial context is set when entering submodule
This commit is contained in:
parent
8a86de85c8
commit
a5c72d056d
@ -23,12 +23,11 @@ type ContextMgr struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewContextMgr(
|
func NewContextMgr(
|
||||||
initialContext types.Context,
|
|
||||||
gui *Gui,
|
gui *Gui,
|
||||||
allContexts *context.ContextTree,
|
allContexts *context.ContextTree,
|
||||||
) *ContextMgr {
|
) *ContextMgr {
|
||||||
return &ContextMgr{
|
return &ContextMgr{
|
||||||
ContextStack: []types.Context{initialContext},
|
ContextStack: []types.Context{},
|
||||||
RWMutex: sync.RWMutex{},
|
RWMutex: sync.RWMutex{},
|
||||||
gui: gui,
|
gui: gui,
|
||||||
allContexts: allContexts,
|
allContexts: allContexts,
|
||||||
|
@ -16,7 +16,7 @@ func (gui *Gui) Helpers() *helpers.Helpers {
|
|||||||
return gui.helpers
|
return gui.helpers
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) resetControllers() {
|
func (gui *Gui) resetHelpersAndControllers() {
|
||||||
helperCommon := gui.c
|
helperCommon := gui.c
|
||||||
refsHelper := helpers.NewRefsHelper(helperCommon)
|
refsHelper := helpers.NewRefsHelper(helperCommon)
|
||||||
|
|
||||||
|
@ -291,14 +291,18 @@ func (gui *Gui) onNewRepo(startArgs appTypes.StartArgs, reuseState bool) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
gui.resetState(startArgs, reuseState)
|
contextToPush := gui.resetState(startArgs, reuseState)
|
||||||
|
|
||||||
gui.resetControllers()
|
gui.resetHelpersAndControllers()
|
||||||
|
|
||||||
if err := gui.resetKeybindings(); err != nil {
|
if err := gui.resetKeybindings(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := gui.c.PushContext(contextToPush); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,7 +315,7 @@ func (gui *Gui) onNewRepo(startArgs appTypes.StartArgs, reuseState bool) error {
|
|||||||
// it gets a bit confusing to land back in the status panel when visiting a repo
|
// it gets a bit confusing to land back in the status panel when visiting a repo
|
||||||
// you've already switched from. There's no doubt some easy way to make the UX
|
// you've already switched from. There's no doubt some easy way to make the UX
|
||||||
// optimal for all cases but I'm too lazy to think about what that is right now
|
// optimal for all cases but I'm too lazy to think about what that is right now
|
||||||
func (gui *Gui) resetState(startArgs appTypes.StartArgs, reuseState bool) {
|
func (gui *Gui) resetState(startArgs appTypes.StartArgs, reuseState bool) types.Context {
|
||||||
currentDir, err := os.Getwd()
|
currentDir, err := os.Getwd()
|
||||||
|
|
||||||
if reuseState {
|
if reuseState {
|
||||||
@ -326,7 +330,7 @@ func (gui *Gui) resetState(startArgs appTypes.StartArgs, reuseState bool) {
|
|||||||
gui.State.CurrentPopupOpts = nil
|
gui.State.CurrentPopupOpts = nil
|
||||||
gui.Mutexes.PopupMutex.Unlock()
|
gui.Mutexes.PopupMutex.Unlock()
|
||||||
|
|
||||||
return
|
return gui.c.CurrentContext()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
gui.c.Log.Error(err)
|
gui.c.Log.Error(err)
|
||||||
@ -335,7 +339,6 @@ func (gui *Gui) resetState(startArgs appTypes.StartArgs, reuseState bool) {
|
|||||||
|
|
||||||
contextTree := gui.contextTree()
|
contextTree := gui.contextTree()
|
||||||
|
|
||||||
initialContext := initialContext(contextTree, startArgs)
|
|
||||||
initialScreenMode := initialScreenMode(startArgs, gui.Config)
|
initialScreenMode := initialScreenMode(startArgs, gui.Config)
|
||||||
|
|
||||||
gui.State = &GuiRepoState{
|
gui.State = &GuiRepoState{
|
||||||
@ -356,16 +359,14 @@ func (gui *Gui) resetState(startArgs appTypes.StartArgs, reuseState bool) {
|
|||||||
},
|
},
|
||||||
ScreenMode: initialScreenMode,
|
ScreenMode: initialScreenMode,
|
||||||
// TODO: only use contexts from context manager
|
// TODO: only use contexts from context manager
|
||||||
ContextMgr: NewContextMgr(initialContext, gui, contextTree),
|
ContextMgr: NewContextMgr(gui, contextTree),
|
||||||
Contexts: contextTree,
|
Contexts: contextTree,
|
||||||
WindowViewNameMap: initialWindowViewNameMap(contextTree),
|
WindowViewNameMap: initialWindowViewNameMap(contextTree),
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := gui.c.PushContext(initialContext); err != nil {
|
|
||||||
gui.c.Log.Error(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
gui.RepoStateMap[Repo(currentDir)] = gui.State
|
gui.RepoStateMap[Repo(currentDir)] = gui.State
|
||||||
|
|
||||||
|
return initialContext(contextTree, startArgs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func initialWindowViewNameMap(contextTree *context.ContextTree) *utils.ThreadSafeMap[string, string] {
|
func initialWindowViewNameMap(contextTree *context.ContextTree) *utils.ThreadSafeMap[string, string] {
|
||||||
|
@ -52,8 +52,8 @@ func (self *Gui) GetCheatsheetKeybindings() []*types.Binding {
|
|||||||
self.helpers = helpers.NewStubHelpers()
|
self.helpers = helpers.NewStubHelpers()
|
||||||
self.State = &GuiRepoState{}
|
self.State = &GuiRepoState{}
|
||||||
self.State.Contexts = self.contextTree()
|
self.State.Contexts = self.contextTree()
|
||||||
self.State.ContextMgr = NewContextMgr(nil, self, self.State.Contexts)
|
self.State.ContextMgr = NewContextMgr(self, self.State.Contexts)
|
||||||
self.resetControllers()
|
self.resetHelpersAndControllers()
|
||||||
bindings, _ := self.GetInitialKeybindings()
|
bindings, _ := self.GetInitialKeybindings()
|
||||||
return bindings
|
return bindings
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user