From bf7dd663c1cea6d28ac3e79b7da7fc14e7bb23fc Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Thu, 26 Dec 2019 12:35:50 +0300 Subject: [PATCH 1/2] Propagate error from parsing keybinding (#129) --- runtime/ui/key/binding.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/runtime/ui/key/binding.go b/runtime/ui/key/binding.go index 40533b4c..86971459 100644 --- a/runtime/ui/key/binding.go +++ b/runtime/ui/key/binding.go @@ -62,7 +62,10 @@ func NewBindingFromConfig(gui *gocui.Gui, influence string, configKeys []string, logrus.Debugf("parsing keybinding '%s' --> '%s'", configKey, bindStr) keys, err := keybinding.ParseAll(bindStr) - if err == nil && keys != nil && len(keys) > 0 { + if err != nil { + return nil, err + } + if keys != nil && len(keys) > 0 { parsedKeys = keys break } From 20ec5cf2aaf273eaa941337af1213b8033fab2b5 Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Thu, 26 Dec 2019 13:22:48 +0300 Subject: [PATCH 2/2] Simplify nil check for slice len() for nil slices is defined as zero (gosimple) --- runtime/ui/key/binding.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/ui/key/binding.go b/runtime/ui/key/binding.go index 86971459..5d4605a3 100644 --- a/runtime/ui/key/binding.go +++ b/runtime/ui/key/binding.go @@ -65,7 +65,7 @@ func NewBindingFromConfig(gui *gocui.Gui, influence string, configKeys []string, if err != nil { return nil, err } - if keys != nil && len(keys) > 0 { + if len(keys) > 0 { parsedKeys = keys break }