From 1b91b68e7385239783bee818974c4ce2032b7039 Mon Sep 17 00:00:00 2001
From: Robin Jarry <robin@jarry.cc>
Date: Sun, 7 Aug 2022 22:04:25 +0200
Subject: [PATCH] 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: 5e600d7ab46b ("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>
---
 config/bindings.go | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/config/bindings.go b/config/bindings.go
index 94d7d72..15c2ce3 100644
--- a/config/bindings.go
+++ b/config/bindings.go
@@ -149,8 +149,11 @@ func FormatKeyStrokes(keystrokes []KeyStroke) string {
 		s := ""
 		for name, ks := range keyNames {
 			if ks.Modifiers == stroke.Modifiers && ks.Key == stroke.Key && ks.Rune == stroke.Rune {
-				if name == "cr" {
+				switch name {
+				case "cr", "c-m":
 					name = "enter"
+				case "c-i":
+					name = "tab"
 				}
 				s = fmt.Sprintf("<%s>", name)
 				break