mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-15 11:56:37 +02:00
concurrent-safe handling of context state
This commit is contained in:
parent
9c866fd49c
commit
2488e0044d
@ -87,6 +87,7 @@ type ContextTree struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) switchContext(c Context) error {
|
func (gui *Gui) switchContext(c Context) error {
|
||||||
|
gui.g.Update(func(*gocui.Gui) error {
|
||||||
// push onto stack
|
// push onto stack
|
||||||
// if we are switching to a side context, remove all other contexts in the stack
|
// if we are switching to a side context, remove all other contexts in the stack
|
||||||
if c.GetKind() == SIDE_CONTEXT {
|
if c.GetKind() == SIDE_CONTEXT {
|
||||||
@ -104,6 +105,9 @@ func (gui *Gui) switchContext(c Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return gui.activateContext(c)
|
return gui.activateContext(c)
|
||||||
|
})
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// switchContextToView is to be used when you don't know which context you
|
// 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 {
|
func (gui *Gui) returnFromContext() error {
|
||||||
|
gui.g.Update(func(*gocui.Gui) error {
|
||||||
// TODO: add mutexes
|
// TODO: add mutexes
|
||||||
|
|
||||||
if len(gui.State.ContextStack) == 1 {
|
if len(gui.State.ContextStack) == 1 {
|
||||||
@ -133,6 +138,9 @@ func (gui *Gui) returnFromContext() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return gui.activateContext(newContext)
|
return gui.activateContext(newContext)
|
||||||
|
})
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) deactivateContext(c Context) error {
|
func (gui *Gui) deactivateContext(c Context) error {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user