bindings: fix FormatKeyStrokes for <tab> and <enter>

Sometimes, a <tab> or <enter> key in a binding will be formatted as
a <c-i> or <c-m> respectively. This is because these keys are
equivalent. Prefer their canonical name instead of the control modifier
variant.

Fixes: 5e600d7ab4 ("binds: fix ctrl-i and ctrl-m key definitions")
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Koni Marti <koni.marti@gmail.com>
This commit is contained in:
Robin Jarry 2022-08-07 22:04:25 +02:00
parent d1838c8063
commit 1b91b68e73

View file

@ -149,8 +149,11 @@ func FormatKeyStrokes(keystrokes []KeyStroke) string {
s := "" s := ""
for name, ks := range keyNames { for name, ks := range keyNames {
if ks.Modifiers == stroke.Modifiers && ks.Key == stroke.Key && ks.Rune == stroke.Rune { if ks.Modifiers == stroke.Modifiers && ks.Key == stroke.Key && ks.Rune == stroke.Rune {
if name == "cr" { switch name {
case "cr", "c-m":
name = "enter" name = "enter"
case "c-i":
name = "tab"
} }
s = fmt.Sprintf("<%s>", name) s = fmt.Sprintf("<%s>", name)
break break