diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-06 10:09:53 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-06 19:34:32 +1000 |
commit | 02f45b679f65e5d862d0d4cb2d24b0116cd13796 (patch) | |
tree | 2b99ba20d680079f47057c7f456086340e9dd9b0 | |
parent | b1cda65dcfdc5465f9fca582105fb0aa741abff5 (diff) |
do not double-append contexts to the stack
-rw-r--r-- | pkg/gui/context.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/pkg/gui/context.go b/pkg/gui/context.go index 60f834835..f20e3ff33 100644 --- a/pkg/gui/context.go +++ b/pkg/gui/context.go @@ -416,7 +416,10 @@ func (gui *Gui) pushContextDirect(c Context) error { } } gui.State.ContextManager.ContextStack = []Context{c} - } else { + } else if len(gui.State.ContextManager.ContextStack) == 0 || gui.State.ContextManager.ContextStack[len(gui.State.ContextManager.ContextStack)-1].GetKey() != c.GetKey() { + // Do not append if the one at the end is the same context (e.g. opening a menu from a menu) + // In that case we'll just close the menu entirely when the user hits escape. + // TODO: think about other exceptional cases gui.State.ContextManager.ContextStack = append(gui.State.ContextManager.ContextStack, c) } |