diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b923101..d8702551 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), - The string representation of commands shown when displaying keybindings is simplified (e.g. `cd ~` instead of `cd -- [~]`) (#2165). - `yes-no-prompts` now use the same design everywhere (#2212). - Logs generated by `-log ` now get appended to `` instead of overwriting it (#2215). -- The `showbinds` menu no longer shows an unnecessary `mode` column (#2226). +- The `showbinds` menu no longer shows an unnecessary `mode` column (#2226) (#2228). ### Added diff --git a/app.go b/app.go index b92142ea..5aacad77 100644 --- a/app.go +++ b/app.go @@ -562,16 +562,16 @@ func (app *app) runShell(s string, args []string, prefix string) { gState.data["maps"] = listBinds(map[string]map[string]expr{ "n": gOpts.nkeys, "v": gOpts.vkeys, - }) + }, true) gState.data["nmaps"] = listBinds(map[string]map[string]expr{ "n": gOpts.nkeys, - }) + }, true) gState.data["vmaps"] = listBinds(map[string]map[string]expr{ "v": gOpts.vkeys, - }) + }, true) gState.data["cmaps"] = listBinds(map[string]map[string]expr{ "c": gOpts.cmdkeys, - }) + }, true) gState.data["cmds"] = listCmds(gOpts.cmds) gState.data["jumps"] = listJumps(app.nav.jumpList, app.nav.jumpListInd) gState.data["history"] = listHistory(app.cmdHistory) diff --git a/ui.go b/ui.go index aec38fab..77a62c48 100644 --- a/ui.go +++ b/ui.go @@ -1325,7 +1325,7 @@ func findBinds(keys map[string]expr, prefix string) (binds map[string]expr, ok b return } -func listBinds(binds map[string]map[string]expr) string { +func listBinds(binds map[string]map[string]expr, showMode bool) string { t := new(tabwriter.Writer) b := new(bytes.Buffer) @@ -1363,17 +1363,16 @@ func listBinds(binds map[string]map[string]expr) string { t.Init(b, 0, gOpts.tabstop, 2, '\t', 0) - 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 + if showMode { 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) } + } else { + fmt.Fprintln(t, "keys\tcommand") + for _, e := range entries { + fmt.Fprintf(t, "%s\t%s\n", e.key, e.cmd) + } } t.Flush() @@ -1632,7 +1631,7 @@ func (ui *ui) readNormalEvent(ev tcell.Event, nav *nav) expr { if gOpts.showbinds { ui.menu = listBinds(map[string]map[string]expr{ mode: binds, - }) + }, false) // mode is obvious here; no need to clutter the menu } return draw }