Fix alt-, for --expect

This commit is contained in:
Junegunn Choi 2020-12-31 03:37:25 +09:00
parent 408c04f25f
commit 7136cfc68b
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627
2 changed files with 6 additions and 0 deletions

View File

@ -449,6 +449,7 @@ func parseKeyChords(str string, message string) map[tui.Event]string {
errorExit(message)
}
str = regexp.MustCompile("(?i)(alt-),").ReplaceAllString(str, "$1"+string(escapedComma))
tokens := strings.Split(str, ",")
if str == "," || strings.HasPrefix(str, ",,") || strings.HasSuffix(str, ",,") || strings.Contains(str, ",,,") {
tokens = append(tokens, ",")
@ -459,6 +460,7 @@ func parseKeyChords(str string, message string) map[tui.Event]string {
if len(key) == 0 {
continue // ignore
}
key = strings.ReplaceAll(key, string(escapedComma), ",")
lkey := strings.ToLower(key)
add := func(e tui.EventType) {
chords[e.AsEvent()] = key

View File

@ -225,6 +225,10 @@ func TestParseKeysWithComma(t *testing.T) {
pairs = parseKeyChords(",,,", "")
checkN(len(pairs), 1)
check(pairs, tui.Key(','), ",")
pairs = parseKeyChords(",ALT-,,", "")
checkN(len(pairs), 1)
check(pairs, tui.AltKey(','), "ALT-,")
}
func TestBind(t *testing.T) {