simplify the code around unbinding keys
@@ -350,10 +350,15 @@ func BindKey(k, v string) {
helpBinding = ""
}
- if v == "UnbindKey" {
+ actionNames := strings.Split(v, ",")
+ if actionNames[0] == "UnbindKey" {
delete(bindings, key)
+ if len(actionNames) == 1 {
+ actionNames = make([]string, 0, 0)
} else {
- actionNames := strings.Split(v, ",")
+ actionNames = append(actionNames[:0], actionNames[1:]...)
+ }
+ }
actions := make([]func(*View, bool) bool, 0, len(actionNames))
for _, actionName := range actionNames {
actions = append(actions, findAction(actionName))
@@ -361,7 +366,6 @@ func BindKey(k, v string) {
bindings[key] = actions
}
-}
// DefaultBindings returns a map containing micro's default keybindings
func DefaultBindings() map[string]string {
