1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-03-03 15:02:52 +02:00

concurrent-safe handling of context state

This commit is contained in:
Jesse Duffield 2020-08-18 22:41:27 +10:00
parent 9c866fd49c
commit 2488e0044d

View File

@ -87,6 +87,7 @@ type ContextTree struct {
}
func (gui *Gui) switchContext(c Context) error {
gui.g.Update(func(*gocui.Gui) error {
// push onto stack
// if we are switching to a side context, remove all other contexts in the stack
if c.GetKind() == SIDE_CONTEXT {
@ -104,6 +105,9 @@ func (gui *Gui) switchContext(c Context) error {
}
return gui.activateContext(c)
})
return nil
}
// switchContextToView is to be used when you don't know which context you
@ -114,6 +118,7 @@ func (gui *Gui) switchContextToView(viewName string) error {
}
func (gui *Gui) returnFromContext() error {
gui.g.Update(func(*gocui.Gui) error {
// TODO: add mutexes
if len(gui.State.ContextStack) == 1 {
@ -133,6 +138,9 @@ func (gui *Gui) returnFromContext() error {
}
return gui.activateContext(newContext)
})
return nil
}
func (gui *Gui) deactivateContext(c Context) error {