summaryrefslogtreecommitdiffstats
path: root/pkg/gui/gui_common.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-06-13 11:01:26 +1000
committerJesse Duffield <jessedduffield@gmail.com>2022-08-06 13:49:11 +1000
commit524bf83a4a681408c3fb57818f6968cab632e0ae (patch)
tree8858b4ee8d4670dcdd1637fe5fedf00ff080c154 /pkg/gui/gui_common.go
parent6dfef08efc5c7f262194c0af35fd777428f33a1a (diff)
refactor to only have one context per view
Diffstat (limited to 'pkg/gui/gui_common.go')
-rw-r--r--pkg/gui/gui_common.go22
1 files changed, 21 insertions, 1 deletions
diff --git a/pkg/gui/gui_common.go b/pkg/gui/gui_common.go
index 89abe92ba..587a7fb86 100644
--- a/pkg/gui/gui_common.go
+++ b/pkg/gui/gui_common.go
@@ -1,6 +1,8 @@
package gui
import (
+ "errors"
+
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
"github.com/jesseduffield/lazygit/pkg/config"
"github.com/jesseduffield/lazygit/pkg/gui/types"
@@ -39,7 +41,17 @@ func (self *guiCommon) RunSubprocess(cmdObj oscommands.ICmdObj) (bool, error) {
}
func (self *guiCommon) PushContext(context types.Context, opts ...types.OnFocusOpts) error {
- return self.gui.pushContext(context, opts...)
+ singleOpts := types.OnFocusOpts{}
+ if len(opts) > 0 {
+ // using triple dot but you should only ever pass one of these opt structs
+ if len(opts) > 1 {
+ return errors.New("cannot pass multiple opts to pushContext")
+ }
+
+ singleOpts = opts[0]
+ }
+
+ return self.gui.pushContext(context, singleOpts)
}
func (self *guiCommon) PopContext() error {
@@ -50,6 +62,14 @@ func (self *guiCommon) CurrentContext() types.Context {
return self.gui.currentContext()
}
+func (self *guiCommon) CurrentStaticContext() types.Context {
+ return self.gui.currentStaticContext()
+}
+
+func (self *guiCommon) IsCurrentContext(c types.Context) bool {
+ return self.CurrentContext().GetKey() == c.GetKey()
+}
+
func (self *guiCommon) GetAppState() *config.AppState {
return self.gui.Config.GetAppState()
}