mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-19 12:12:42 +02:00
honour options menu press
This commit is contained in:
parent
bd67bba751
commit
652c97d239
@ -128,33 +128,37 @@ func (gui *Gui) pushContextWithView(viewName string) error {
|
|||||||
|
|
||||||
func (gui *Gui) returnFromContext() error {
|
func (gui *Gui) returnFromContext() error {
|
||||||
gui.g.Update(func(*gocui.Gui) error {
|
gui.g.Update(func(*gocui.Gui) error {
|
||||||
gui.State.ContextManager.Lock()
|
return gui.returnFromContextSync()
|
||||||
|
|
||||||
if len(gui.State.ContextManager.ContextStack) == 1 {
|
|
||||||
// cannot escape from bottommost context
|
|
||||||
gui.State.ContextManager.Unlock()
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
n := len(gui.State.ContextManager.ContextStack) - 1
|
|
||||||
|
|
||||||
currentContext := gui.State.ContextManager.ContextStack[n]
|
|
||||||
newContext := gui.State.ContextManager.ContextStack[n-1]
|
|
||||||
|
|
||||||
gui.State.ContextManager.ContextStack = gui.State.ContextManager.ContextStack[:n]
|
|
||||||
|
|
||||||
gui.State.ContextManager.Unlock()
|
|
||||||
|
|
||||||
if err := gui.deactivateContext(currentContext); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return gui.activateContext(newContext)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) returnFromContextSync() error {
|
||||||
|
gui.State.ContextManager.Lock()
|
||||||
|
|
||||||
|
if len(gui.State.ContextManager.ContextStack) == 1 {
|
||||||
|
// cannot escape from bottommost context
|
||||||
|
gui.State.ContextManager.Unlock()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
n := len(gui.State.ContextManager.ContextStack) - 1
|
||||||
|
|
||||||
|
currentContext := gui.State.ContextManager.ContextStack[n]
|
||||||
|
newContext := gui.State.ContextManager.ContextStack[n-1]
|
||||||
|
|
||||||
|
gui.State.ContextManager.ContextStack = gui.State.ContextManager.ContextStack[:n]
|
||||||
|
|
||||||
|
gui.State.ContextManager.Unlock()
|
||||||
|
|
||||||
|
if err := gui.deactivateContext(currentContext); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return gui.activateContext(newContext)
|
||||||
|
}
|
||||||
|
|
||||||
func (gui *Gui) deactivateContext(c Context) error {
|
func (gui *Gui) deactivateContext(c Context) error {
|
||||||
view, _ := gui.g.View(c.GetViewName())
|
view, _ := gui.g.View(c.GetViewName())
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ func (gui *Gui) getMenuOptions() map[string]string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleMenuClose() error {
|
func (gui *Gui) handleMenuClose() error {
|
||||||
return gui.returnFromContext()
|
return gui.returnFromContextSync()
|
||||||
}
|
}
|
||||||
|
|
||||||
type createMenuOptions struct {
|
type createMenuOptions struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user