summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2020-12-31 03:37:25 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2020-12-31 03:38:46 +0900
commit7136cfc68bfb1b306d801ad8a5094a30c79b544d (patch)
treea2881fae9f642a055d0ac0c1010f06429aa10a8f
parent408c04f25fd93f01488409e18ef94d56f8d3f952 (diff)
Fix alt-, for --expect
-rw-r--r--src/options.go2
-rw-r--r--src/options_test.go4
2 files changed, 6 insertions, 0 deletions
diff --git a/src/options.go b/src/options.go
index c33f14ce..840f1764 100644
--- a/src/options.go
+++ b/src/options.go
@@ -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
diff --git a/src/options_test.go b/src/options_test.go
index 4311aa4d..b1068964 100644
--- a/src/options_test.go
+++ b/src/options_test.go
@@ -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) {