1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-11-29 22:48:24 +02:00

Return whether the context has a parent or not along with that parent

There has got to be a better way around this but if we're returning a Context
from a function (Context is an interface, not a concrete type), even if we
return nil, on the calling end it won't be equal to nil because an interface
value is a tuple of the type and the value meaning it's never itself nil,
unless both values in the tuple are nil.

So we're explicitly returning whether or not the underlying concrete type is nil.
This commit is contained in:
Jesse Duffield
2020-08-24 08:26:42 +10:00
committed by github-actions[bot]
parent 0f7003d939
commit f172f20219
3 changed files with 15 additions and 8 deletions

View File

@@ -46,7 +46,9 @@ type Context interface {
SetWindowName(string)
GetKey() string
SetParentContext(Context)
GetParentContext() Context
// we return a bool here to tell us whether or not the returned value just wraps a nil
GetParentContext() (Context, bool)
GetOptionsMap() map[string]string
}
@@ -80,8 +82,8 @@ func (c BasicContext) SetParentContext(Context) {
panic("can't set parent context on basic context")
}
func (c BasicContext) GetParentContext() Context {
panic("can't get parent context on basic context")
func (c BasicContext) GetParentContext() (Context, bool) {
return nil, false
}
func (c BasicContext) HandleRender() error {