From 4e0e492427a6517a9311546da10a4e4b91d883e5 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Fri, 22 May 2015 00:02:14 +0900 Subject: [PATCH] Minor refactoring --- src/options.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/options.go b/src/options.go index 97efaa7..1531749 100644 --- a/src/options.go +++ b/src/options.go @@ -295,17 +295,20 @@ func parseTheme(str string) *curses.ColorTheme { func parseKeymap(keymap map[int]actionType, toggleSort bool, str string) (map[int]actionType, bool) { for _, pairStr := range strings.Split(str, ",") { + fail := func() { + errorExit("invalid key binding: " + pairStr) + } pair := strings.Split(pairStr, ":") if len(pair) != 2 { - errorExit("invalid key binding: " + pairStr) + fail() } keys := parseKeyChords(pair[0], "key name required") if len(keys) != 1 { - errorExit("invalid key binding: " + pairStr) + fail() } key := keys[0] act := strings.ToLower(pair[1]) - switch strings.ToLower(pair[1]) { + switch act { case "beginning-of-line": keymap[key] = actBeginningOfLine case "abort":