From b90bd273f759da89fdd63ef4b7bea59b550ad846 Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Wed, 24 Aug 2016 13:08:49 +0300 Subject: [PATCH] sort key bindings before listing Mentioned in #1. --- ui.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ui.go b/ui.go index 027e7ee..4ef6f30 100644 --- a/ui.go +++ b/ui.go @@ -7,6 +7,7 @@ import ( "log" "os" "path" + "sort" "strings" "text/tabwriter" "time" @@ -520,10 +521,16 @@ func (ui *UI) listBinds(binds map[string]Expr) { t := new(tabwriter.Writer) b := new(bytes.Buffer) + var keys []string + for k := range binds { + keys = append(keys, k) + } + sort.Strings(keys) + t.Init(b, 0, gOpts.tabstop, 2, '\t', 0) fmt.Fprintln(t, "keys\tcommand") - for key, expr := range binds { - fmt.Fprintf(t, "%s\t%v\n", key, expr) + for _, k := range keys { + fmt.Fprintf(t, "%s\t%v\n", k, binds[k]) } t.Flush()