diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-08-24 08:26:42 +1000 |
---|---|---|
committer | github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | 2020-08-23 22:30:32 +0000 |
commit | f172f20219096e6dac26f8f01e7a7fe1f3b5d3ef (patch) | |
tree | 46d197e8f2b25e3075ac89dd5c4245d25b300d63 /pkg/gui/context.go | |
parent | 0f7003d939a969920ffdb5f2d28fca2fd0eb7f65 (diff) |
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.
Diffstat (limited to 'pkg/gui/context.go')
-rw-r--r-- | pkg/gui/context.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/pkg/gui/context.go b/pkg/gui/context.go index b198cb7e9..937106953 100644 --- a/pkg/gui/context.go +++ b/pkg/gui/context.go @@ -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 { |