This commit is contained in:
Kovid Goyal 2023-04-04 21:18:27 +05:30
parent 6dcc7ad0c7
commit 3ee77a3a57
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 16 additions and 0 deletions

View File

@ -28,6 +28,7 @@ func load_config(opts *Options) (ans *Config, err error) {
if err != nil {
return nil, err
}
ans.KeyboardShortcuts = config.ResolveShortcuts(ans.KeyboardShortcuts)
return ans, nil
}

View File

@ -9,6 +9,8 @@ import (
"regexp"
"strconv"
"strings"
"golang.org/x/exp/maps"
)
var _ = fmt.Print
@ -288,3 +290,16 @@ func (self *ShortcutTracker) Match(ev *loop.KeyEvent, all_actions []*KeyAction)
}
return nil
}
func ResolveShortcuts(actions []*KeyAction) []*KeyAction {
action_map := make(map[string]*KeyAction, len(actions))
for _, ac := range actions {
key := strings.Join(ac.Normalized_keys, "\x00")
if ac.Name == "no_op" || ac.Name == "no-op" {
delete(action_map, key)
} else {
action_map[key] = ac
}
}
return maps.Values(action_map)
}