From ff169a80b97e22505654940c1da1e6fac3658daf Mon Sep 17 00:00:00 2001 From: CatsDeservePets <145048791+CatsDeservePets@users.noreply.github.com> Date: Sun, 26 Oct 2025 09:43:04 +0100 Subject: [PATCH] Hide mode when listing single-mode binds (#2226) --- ui.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/ui.go b/ui.go index 1b1376ce..aec38fab 100644 --- a/ui.go +++ b/ui.go @@ -1329,6 +1329,7 @@ func listBinds(binds map[string]map[string]expr) string { t := new(tabwriter.Writer) b := new(bytes.Buffer) + // merge keys by command across modes m := make(map[string]map[string]string) for mode, keys := range binds { for key, expr := range keys { @@ -1343,6 +1344,7 @@ func listBinds(binds map[string]map[string]expr) string { mode, key, cmd string } + // collect normalized entries var entries []entry for key, cmds := range m { for cmd, modes := range cmds { @@ -1360,9 +1362,18 @@ func listBinds(binds map[string]map[string]expr) string { }) t.Init(b, 0, gOpts.tabstop, 2, '\t', 0) - fmt.Fprintln(t, "mode\tkeys\tcommand") - for _, e := range entries { - fmt.Fprintf(t, "%s\t%s\t%s\n", e.mode, e.key, e.cmd) + + if len(binds) == 1 { + fmt.Fprintln(t, "keys\tcommand") + for _, e := range entries { + fmt.Fprintf(t, "%s\t%s\n", e.key, e.cmd) + } + } else { + // include mode field when listing combined maps + fmt.Fprintln(t, "mode\tkeys\tcommand") + for _, e := range entries { + fmt.Fprintf(t, "%s\t%s\t%s\n", e.mode, e.key, e.cmd) + } } t.Flush()